Copy Code code as follows:
INSERT into table1 (ID, name, address) VALUES (1, YGL, ' Beijing ') apply to T-SQL and Pl/sql
SELECT ID, name, address to table2 from table1 automatically create Table2,t-sql usage
INSERT into table2 (ID, name, address) SELECT ID, name, address from table1
Here is a simple third sentence, because you can specify the columns to be inserted into the talbe2, and the data source can be obtained through a relatively complex query statement, it may be more flexible to use, but we must also note that when we specify the columns of the target table, we must fill in all the Non-empty columns. Otherwise, you won't be able to insert data, and one of the more error-prone areas is when we write the following shorthand format:
Copy Code code as follows:
INSERT into table2 SELECT ID, name, address from table1
At this point, if we skip the column in the target table, the default is to insert data into all the columns of the target table, and the column after the select must be in exactly the same order as the column in the destination table to complete the correct data insertion, which is an easy place to overlook.