Inserting data using Insert
- Insert a full line
- Insert part of a row
- Inserting multiple lines
- Insert the results of some queries
Insert the full line first look at the original customer list:
Insert one line: INSERT into Customersvalues (NULL,' Pep E. Lapew ',' Main Street ',' Los Angeles ',' CA ',' 90046 ',' USA ',NullNULL);
There is also a way to specify the column name, which, when the structure of the table changes, its SQL statements can still be used, and this assignment does not need to be the same as the original structure of the table.
Inserting more than one row inserts multiple rows to tie together several INSERT statements:
INSERT ..... VALUES (,,,,);
INSERT ..... VALUES (,,,,) so that you can insert two records, and if you want to insert a column with the same name, you can merge the INSERT statement as follows:
INSERT into name (,,,,,,,)//subsequent insertion of multiple records with the same column name values (,,,,,,,,,), (...), (...), (.); This will insert three records.
Inserting the retrieved data is actually retrieving the data using the SELECT statement, which is inserted into the table as values, and it is well understood that the following SQL statement merges the Custnew table into the Customer table:
INSERT into Customers (cust_id,Cust_contact,Cust_email,Cust_name,Cust_address,Cust_city,Cust_state,Cust_zip,Cust_country) SELECT cust_id,Cust_contact,Cust_email,Cust_name,Cust_address,Cust_city,Cust_state,Cust_zip,Cust_countryfrom custnew;