Java Reference
In-Depth Information
A.2.2
INSERT
This statement is used to insert an individual row into a table. Syntax:
INSERT INTO <TableName> [<fi eldName>{,<fi eldName>}]
VALUES (<value>{,<value>});
If any attributes are missing, then the row created has default values for these.
The most common default value is NULL . If no attributes are listed, then values for
all attributes must be supplied. For example:
INSERT INTO Stock VALUES(222222,'Rubber',0.57,315,200);
A.2.3
DELETE
This statement is used to delete one or more rows from a specifi ed table. Syntax:
DELETE FROM <TableName> WHERE <condition>;
It is most commonly used to delete a single row from a table, usually by specifying
its primary key in the condition. For example:
DELETE FROM Stock WHERE stockCode = 222222;
Several rows may be deleted at once if multiple rows satisfy the condition. For
example:
DELETE FROM Stock WHERE unitPrice < 1;
A.2.4
UPDATE
This statement is used to modify one or more rows in a specifi ed table. Syntax:
UPDATE <TableName> SET <fi eldName = value>
{,<fi eldName = value >} [WHERE <condition>];
For example:
UPDATE Stock SET unitPrice = 1 WHERE unitPrice < 1;
This would cause the prices of pencils and rulers to rise from 32p and 69p respec-
tively to £1 each.
If all rows are to be affected, then the WHERE clause is omitted.
Search WWH ::




Custom Search