SQL INSERT INTO statement

Source: Internet
Author: User
Tags one table

SQL INSERT INTO statement

Data is added to the table using the INSERT statement. The INSERT into statement can be used to append a record table, or to append multiple records from one table to another.

The syntax for the INSERT statement is:

INSERT into table_name (column1, Column2,...)
VALUES (value1, value2,....)

Instance

INSERT into Antiqueowners (ownerID, Ownerlastname, Ownerfirstname)
VALUES (4, ' Peter ', ' Novitski ')

To add a specific record table, the INSERT into statement is followed by the name of the table and the name of each field. The value of each item in the value is inserted where the value of the corresponding field is in the list: the first value is inserted in the first field, and the second is entered in the second field.

This will cause a record to be inserted into the Antiqueowners table. This new record will have 4 ownerID, a Peter Ownerlastname and Novitski Ownerfirstname.

Note: If you omit the field list, the value of each field in a table must be included, otherwise the operation will fail. Values must also be separated by commas. Text and Date fields must also be enclosed in single quotes (' ").

An AutoNumber field (also known as the Counter-Terrorism field) is a data type that automatically creates and stores a number for each item added to the table. If you record an AutoNumber field appended to a table, you do not want the autonumbered field to be renumbered when it must be included in the AutoNumber field in the query. If the AutoNumber field is not included, the attached item is assigned a new AutoNumber field value.

Sample case

INSERT into Antiqueowners (ownerID, Ownerlastname, Ownerfirstname)
SELECT Employeeidno, LastName, FirstName
From Employeeaddresstab
Le
WHERE city= ' Upton '

A SELECT statement preceded by a multiple-record syntax insert INTO statement, and a table with one or more records added. This is called an append query, copied because it is recorded from one or more tables to another. The table contains records that are not affected by the operation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.