Tips for SQL Server addition, deletion, modification, and query
Insert statement
1. Insert only the default value in the data:
Insert into [DBTrain]. [dbo]. [log_info]
Default values
2. In a field that can be null, if you want to set null, you can press [Ctrl + 0]. Note that zero is not o. If you want to restore the value before modification, press [Esc]
2. Update statement
You can update the first few or a certain percentage of data.
Update top (3) [log_info]
Set info1 = '20140901'
Update top (80) percent [log_info]
Set info2 = '000000'
Three Delete statements can also use top keywords
Select statement
1. With Ties
Run the following SQL: select top 5 * from test
Order by id desc
The results are as follows:
Execute the following SQL statement:
Select top 5 with ties * from test
Order by id desc
It can be seen that the current five records do not show the data with id = 2 completely,
With ties, you can display all the records with id = 2.
To be continued. $ identity, $ RowGuid, Write clause
SQL addition, deletion, modification, and query statements?
SQL statements
(1) Data Record Filtering:
SQL = "select * from data table where field name = field value orderby field name [desc]"
SQL = "select * from data table where field name like '% Field Value %' orderby field name [desc]"
SQL = "selecttop10 * from data table where field name orderby field name [desc]"
SQL = "select * from data table where field name in ('value 1', 'value 2', 'value 3 ')"
SQL = "select * from data table where field name between value 1and value 2"
(2) update data records:
SQL = "update data table set field name = field value where condition expression"
SQL = "update data table set field 1 = value 1, Field 2 = value 2 ...... Field n = value nwhere condition expression"
(3) Delete data records:
SQL = "where efrom data table where condition expression"
SQL = "deletefrom data table" (delete all records of the data table)
(4) add data records:
SQL = "insertinto data table (Field 1, Field 2, Field 3 ...) Values (value 1, value 2, value 3 ...) "
SQL = "insertinto target data table select * from source data table" (add records of source data table to target data table)
The efficiency of adding, deleting, modifying, and querying SQL Server databases is better.
Cannot be generalized, depending on the specific situation