Insert (SQL) - Basic Form

Basic Form

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 and an error returned instead.

Example:

INSERT INTO phone_book (name, NUMBER) VALUES ('John Doe', '555-1212');

Shorthand may also be used, taking advantage of the order of the columns when the table was created. It is not required to specify all columns in the table since any other columns will take their default value or remain null:

  • INSERT INTO table VALUES (value1, )

Example for inserting data into 2 columns in the phone_book table and ignoring any other columns which may be after the first 2 in the table.

INSERT INTO phone_book VALUES ('John Doe', '555-1212');

Read more about this topic:  Insert (SQL)

Famous quotes containing the words basic form, basic and/or form:

    The man who is admired for the ingenuity of his larceny is almost always rediscovering some earlier form of fraud. The basic forms are all known, have all been practicised. The manners of capitalism improve. The morals may not.
    John Kenneth Galbraith (b. 1908)

    Not many appreciate the ultimate power and potential usefulness of basic knowledge accumulated by obscure, unseen investigators who, in a lifetime of intensive study, may never see any practical use for their findings but who go on seeking answers to the unknown without thought of financial or practical gain.
    Eugenie Clark (b. 1922)

    Now, what I want is, Facts. Teach these boys and girls nothing but Facts. Facts alone are wanted in life. Plant nothing else, and root out everything else. You can only form the minds of reasoning animals upon Facts: nothing else will ever be of any service to them. This is the principle on which I bring up my own children, and this is the principle on which I bring up these children. Stick to Facts, sir!
    Charles Dickens (1812–1870)