Insert SQLAn SQL INSERT statement adds a record to a table in a relational database. Insert statements have the following form:
The number of columns and values must be the same. If a column is not specified, the default value for the column is used. The values specified (or implied) by the Example: INSERT INTO phone_book (name, number) VALUES ('John Doe', '555-1212');
When values for all columns in the table are specified, then a shorthand may be used, taking advantage of the order of the columns when the table was created:
Example (assuming that 'name' and 'number' are the only columns in the 'phone_book' table): INSERT INTO phone_book VALUES ('John Doe', '555-1212');
An optional SQL feature (since SQL-92) is the use of row value constructors to insert multiple rows at a time:
This optional feature is supported by DB2 and MySQL. Example (assuming that 'name' and 'number' are the only columns in the 'phone_book' table): INSERT INTO phone_book VALUES ('John Doe', '555-1212'), ('Peter Doe', '555-2323');
- which may be seen as a shorthand for INSERT INTO phone_book VALUES ('John Doe', '555-1212');
INSERT INTO phone_book VALUES ('Peter Doe', '555-2323');
See also |
|
This article is licensed under the GNU Free Documentation License. It uses material from Wikipedia article. Browse Wikipedia for more information. |