1. Index
Add an index, design the interface, right-click on any column--index/key--tap to add an index
2. View
The view is the virtual table we've queried.
Creating views: Create View name
As
SQL query statements--grouping, sorting, in, and so on cannot be written
View Usage: SELECT * from view name
3.SQL programming
Define variable: DECLARE @ variable name data type
Variable assignment: SET @ variable name = value
Output: Print variable or string
Check the car table with the name of the BMW two words
DECLARE @name varchar (20)
Set @name = ' BMW '
SELECT * from car where Name like '% ' [email protected]+ '% '
Check the average of all cars in the car table and output
DECLARE @price decimal (10,4)
Select @price = AVG (price) from Car
print ' average price for all cars: ' +cast (@price as varchar (20))
If ... else usage, if there is no parenthesis, curly braces are replaced with begin end
If judging condition
Begin
The statement to execute
End
Else
Begin
The statement to execute
End
Switch case in C # morphing into database usage
DECLARE @ccname varchar (20)
Set @ccname = ' BMW '
SELECT * from Car where Name is like
Case
When @ccname = ' bmw ' Then '% BMW '
When @ccname = ' Audi ' Then '% Audi '
Else '% '
End
15-07-20 Database--indexed view programming