Insert a row of data
INSERT [into] table name [(column name)] VALUES (Value list)
Precautions:
(1) Each time a row of data is inserted, it is not possible to insert only half a row or a few columns of data inserted data is valid will be checked according to the integrity of the entire line
(2) The data type, precision, and scale of each data value must match the corresponding column
(3) cannot specify a value for an identity column
(4) If you specify that a column is not allowed to be empty when you design the table, you must insert the data
(5) inserted data items that require compliance with the requirements of the check constraint
(6) Columns with default values, you can use the default (default) keyword instead of the inserted value
Source:
INSERT into Student (studentno,loginpwd,studentname,sex,gradeid,phone,address,borndate)
VALUES (' S1200902005 ', default, ' Zhang Feng ', ' Male ', 1, ' 13212345678 ', default, ' 1987-6-2 ')
Inserting multiple rows of data
(1) The first method adds data from an existing table to a table that already exists by using the Insert SELECT statement
INSERT into < table name > (column name) SELECT < column name > from < source table name > (party: The target table must already exist before you can insert data into it)
Source:
INSERT into AddressList (name, address, email) SELECT Sname,saddress,semail from Students
(2) The second method adds data from an existing table to a new table by using the SELECT INTO statement
SELECT (column name) into < table name > from < source table name > (party: The target table does not necessarily exist, and if it does not, it will be created and then inserted into the data)
Source:
SELECT Students.sname,students.saddress,students.semail to AddressList from Students
(3) The third method is inserted by combining the data with the Union keyword
INSERT into < table name > (column name) Select < column name > union select < column name > Union ... (Party: The target table must already exist in order to insert data into it)
Source:
INSERT STUDENTS (Sname,sgrade,ssex)
SELECT ' Zhang can ', 7,1 UNION
SELECT ' Li Yang ', 4,0 UNION
SELECT ' Yang Xiao ', 2,0 UNION
SELECT ' Soup Beauty ', 3,0
SQL Server Database inserts data