--Table data manipulation--
-- Add Table Data --
-- adding data to an existing table --
[Use the database name to manipulate the data table
Go
Insert [into] datasheet [(Field name 1, field name 2, field name 3, ...)] VALUES (value 1, value 2, value 3, ...)
Cases:
Use Commodity Management database
Go
Insert Customer Information Form (customer name, customer number, contact phone) values (' Contacts ', ' 021 ', ' 13927112594 ')
-- generate (add to) a new data table from the table data being queried--
[Use the database name to manipulate the data table
Go
Select field List into new data table name from source data table name [WHERE condition expression]
Cases:
Use Commodity Management database
Go
SELECT * into stock information table from arrival information table where quantity <100
-- Add the queried table data to an existing data table (number of fields, order, and data type to be compatible)--
[Use the database name to manipulate the data table
Go
Insert into is added data already exists data table Select field list from source data table [where condition expression]
Cases:
Use Commodity Management database
Go
Insert into incoming information table, select product number, purchase price, quantity of goods, purchase amount, arrival date from arrival information table where incoming quantity >300
-- modifying table data --
Update the data table name to be modified set field name = new Value [, ...] [From data table list] [Where Condition expression]
Cases:
Use Commodity Management database
Go
Update customer Information table Set mailbox = ' [email protected] ' where customer number = ' 001 '
-- Delete table data --
Delete data table name [from data table list] [where conditional expression] --delete table data only does not delete data table
Cases:
Use Commodity Management database
Delete Customer Information table where customer number = "001"
-- table data query --
SELECT * | field name [, field Name 2, ...] from data table name [WHERE condition expression]
Cases:
Use Commodity Management database
Go
SELECT * From commodity information table
Select product number, product name, origin from product information Form
SELELCT * FROM product information sheet where origin = ' Shenyang, Liaoning '
Note: "--" for the comment text
Simple operation of table data for SQL Server