Changes in the data in the table are reaching, which can also result in changes to the data in the index. Therefore, if the query statement does not require an index, you should delete the useless index to improve efficiency.
One, insert statement
1. Basic INSERT statement
Insert is used to enter data into a table with the following syntax structure:
INSERT into VALUES (value 1, value 2,....)
We can also specify the columns for which you want to insert data:
INSERT into VALUES (value 1, value 2,....)
The entire syntax structure is as follows:
INSERT [TOP (<expression>) [PERCENT]][ into] <Tabular Object> [(<column list>)] [OUTPUT <output clause>]{VALUES(<DataValues>)[, (<data values>)] [M...N] | <TableSource> | EXEC <Prodecure> | DEFAULT VALUES}
Example:
Insert into Values (' USA ')
A new feature was added in SQL Server2008, allowing multiple lines to be inserted at once, separated by commas "," such as:
Insert into values ( ' America '), (' UK ');
2. INSERT into ... SELECT statement
What to do when we need to use some data sources as insert data. Data sources such as:
- Another table in the database
- A completely different database on the same server
- A class of queries or other data from another SQL Server
- Same table
INSERT into ... The SELECT statement completes the ability to insert a block of data at a time. Its syntax structure is a combination of the INSERT statement and the SELECT statement syntax structure:
INSERT into < table name>[<column list>]<SELECT Statement>
Example:
Declart@MyTable Table(SalesOrderIDint, CustomerIDChar(5) )INSERT into @MyTable SELECTSalesorderid,customerid fromAdventureWorks2008.Sales.SalesOrderHeaderWHERESalesOrderIDbetween 44000 and 44010;
second, UPDATE statement
The UPDATE statement updates the data in the table with the simplest syntax structure:
UPDATE SET = WHERE = a value
The complete syntax structure is as follows:
UPDATE [TOP (<expression>)] [PERCENT] <Tabular Object>SET <column> = <Value> [. WRITE (<expression>,<offset>,<length>)][,<column> = <value> [. WRITE (<expression>),<offset>,<length>)]][OUTPUT <source table (s) >][WHERE <restrictive condition>]
BASIC syntax Structure:
UPDATE < table name>SET<column>=< Value>[,<column> = <value>][from< source table (s) >][WHERE <restrictive condition>]
Example:
Update Set = ' China ' where = 4
Third, DELETE statement
The DELETE statement is used to delete data from the table, and the complete syntax structure of the DELETE statement is as follows:
DELETE [TOP (<expression>) [PERCENT] [ from] <Tabular Object> ][OUTPUT <output clause>][From <table or join condition>][WHERE <search condition> | Current of [GLOBAL] <cursorName>]
Its basic grammatical structure is as follows:
DELETE from
[WHERE= value]
Example:
Delete from where = 4
SQL statement-Data manipulation