Insert (Sql)

An SQL INSERT statement adds a record to a table in a relational database. Insert statements have the following form:
   
  • INSERT INTO table (column1, ... ) VALUES (value1, ...)
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 INSERT statement must satisfy all the applicable constraints (such as primary keys, CHECK constraints, and NOT NULL constraints). If a syntax error occurs or if any constraints are violated, the new row is not added to the table. 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:
  • INSERT INTO table VALUES (value1, ...'')
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:
  • INSERT INTO table (column1, ... ) VALUES (value1a, ...), (value2a, ...''), ...
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

 

<< PreviousWord BrowserNext >>
affiliating university
sean burke
rick veitch
richard jefferson
dock boggs
kendall college of art and design
pyknosis
u.s. highway 259
list of florida county name etymologies
u.s. highway 360
wrestling mask
fort ancient
u.s. highway 460
shawn marion
battle of the bismarck sea
u.s. highway 163
tarabish
bruce michael hall
river lambourn
u.s. highway 264
darrell rankin
list of fictional people who lived more than once
u.s. highway 165
multiple incarnations
catalina ponor
u.s. highway 167
u.s. highway 169
sven butenschon
juicy juice
miladinov brothers
u.s. highway 270
grand rapids community college
eats, shoots and leaves
uss fairfax (dd 93)
u.s. highway 176
sidney j. catts
foxfire (1996 movie)
sandal (footwear)
uss monticello (lsd 35)
diazotrophs
u.s. highway 278
u.s. highway 378
bob (blackadder character)
toyota a engine