Insert (SQL)
Appearance
A SQL INSERT statement adds a record to a table in a relational database.
Insert statements have the following form:
INSERT INTO table (field1, [field2, ... ]) VALUES (value1, [value2, ...])
The number of fields and values must be the same. All of the mandatory (NOT NULL) fields must be specified and any of the optional fields may be specified. No field may be repeated.
Example:
INSERT INTO Phone_book (Name, Number) VALUES ('John Doe', '555-1212')
Common reasons for an INSERT statement failing include the following
- failure to include values for fields that may not be NULL
- duplication of the table's primary key
- violation of other database constraints