Java Reference
In-Depth Information
3. Creating a Table
create table Accounts(acctNum int primary key , surname
varchar(15), fi rstNames varchar(25), balance real);
[Note the setting of the primary key!]
4. Inserting Rows
insert into Accounts values(123456, 'Black', 'James
Michael', 123.45);
5. Selecting, Updating and Deleting Rows
select * from Accounts;
update Accounts set balance=999.99 where acctNum=123456;
delete from Accounts where acctNum = 234567;
6. Disconnecting and Reconnecting
connect 'jdbc:derby:<DbPath&Name>';
Note that relative addressing may be used.
7. Quitting
8. Using Scripts
Unless dealing with only one or two SQL statements, one should always use ij
scripts. First place all of the required SQL statements into a text fi le with an
appropriate name (e.g., AccountsScript.sql ). This fi le may then be run in any one
of the following three ways…
( i ) Use the ij command, supplying the input fi le as a command line argument.
java AccountsScript.sql
(ii) Redirect standard input [see Sect. 4.3 ] to come from the script fi le.
java < AccountsScript.sql
(iii) From the ij prompt, use the run command.
run 'AccountsScript.sql';
Search WWH ::

Custom Search