Databases Reference
In-Depth Information
This command can be used to delete all data from a table, but it will not delete the
structure of the table. Use DROP for that purpose.
You can use DELETE to remove records from tables that have a one-to-many
relationship. If cascading delete is enabled when you delete a row from the one side of
the relationship, all matching rows are deleted from the many side. The action of the
DELETE statement is not reversable. Always make backups before deleting! You can run
a SELECT operation before DELETE to see which rows will be affected by the DELETE
operation.
6.7.7 The INSERT INTO Statement
The INSERT INTO statement is designed to insert new rows into a table. This can be
done by specifying the values of a new row using this syntax:
INSERT INTO Target [( FieldName ,...)]
VALUES ( Value1 ,...)
If you do not specify the FieldName (s), then you must include values for each field in
the table.
Let's look at several examples of the INSERT INTO statement. The following statement
inserts a new row into the BOOKS table:
INSERT INTO BOOKS
VALUES ("1-000-00000-0", "SQL is Fun",1,25.00);
The following statement inserts a new row into the BOOKS table. The Price and PubID
columns have NULL values.
INSERT INTO BOOKS (ISBN,Title)
VALUES ("1-1111-1111-1","Gone Fishing");
To insert multiple rows, use this syntax:
INSERT INTO Target [( FieldName ,...)]
SELECT FieldName ,...
FROM TableExpression
In both syntaxes, Target is the name of the table or query into which rows are to be
inserted. In the case of a query, that query must be updatable and all updates will be
reflected in the underlying tables. TableExpression is the name of the table from which
records are inserted, the name of a saved query, or a SELECT statement.
Assume that NEWBOOKS is a table with three fields: ISBN, PubID, and Price. The
following statement inserts rows from BOOKS into NEWBOOKS. It inserts only those
books with Price > $20.00.
Search WWH ::




Custom Search