Objective:
Database operation can not avoid the operation of the data, the operation method is similar, original aim, write a variety of flower operation of the fundamental additions and deletions to check four operations, today we will say three ways to increase the operation
Body:
Adding a data row to a database adds new data information
Precautions:
1. Insert the data row to insert the complete, do not insert only a few columns
2. The data type, precision, and scale of each value must match the corresponding column;
3. You cannot specify a value for an identity column because its number is automatically increased;
4. When inserting to conform to the constraint
5. Columns with default values, you can use the default (default) keyword instead of the inserted value
Format:
(1) INSERT [into] < table name > [column Name] Values < value list >
Cases:
INSERT VALUES ('s001',' Zhang San ',' male '), (' s002',' John Doe ', ' male ')
(2) INSERT into < table name > (column name) SELECT < column name > from < source table name >
Precautions:
1. The first table must be present
2. You can add multiple
Cases:
INSERT into table1 (A1,B1,C1) SELECT A2,B2,C2 from Table2
(both Table1 and table2 exist)
(3) SELECT (column name) into < table name > from < source table name >
Precautions:
1. The first table name must not exist because the table is automatically built when inserted and the data from the source table is copied to the newly created table
2. Can only be added once, cannot be added repeatedly
Cases:
SELECT (A4,B4,C4) into Table3 from Table4 (table3 not present, a4,b4,c4 in Table4)
Three ways to increase SQL Server Basic operations