SQL classification:
DDL data Definition Language CREATE ALTER DROP DECLARE
DML Data Manipulation Language SELECT DELETE UPDATE INSERT
DCL Data Control Language GRANT REVOKE COMMIT ROLLBACK
Index creation and deletion note: The index is immutable and you want to change the re-built
Create [unique] index idxname on tabname (col ...)
Drop INDEX Idxname
Creation and deletion of views
CREATE VIEW viewname AS SELECT statement
Drop View ViewName
Like
SELECT * FROM table1 where field1 like '%value1% '
Sort, total, sum, average, maximum, minimum
SELECT * FROM table1 ORDER by FIELD1,FIELD2 [DESC]
Select Count * as TotalCount from table1
Select SUM (field1) as Sumvalue from table1
Select AVG (field1) as Avgvalue from table1
Select Max (field1) as MaxValue from table1
Select min (field1) as MaxValue from table1
Operator
UNION derives a result table combination table1 and table2 by combining the other two result tables (for example, TABLE1 and TABLE2) and eliminating any duplicate rows in the table
UNION all does not eliminate duplicate rows
EXCEPT a result table that is not table2 in Table1 by including all rows in TABLE1 but not in TABLE2 and eliminating all duplicate rows
EXCEPT all does not eliminate duplicate rows
INTERSECT derive a result table by including only rows in TABLE1 and TABLE2 and eliminate all duplicate rows in table1 also in table2
INTERSECT all does not eliminate duplicate rows
External links
Left outer join left JOIN OUTER JOIN result set includes both the matching row of the join table and all rows of the LEFT join table
Select A.a, A.B, A.C, B.C, B.D, B.f from a left OUTER JOIN b on a.a = B.C
Right outer join Right connect outer JOIN result set includes both matching join row for join table and all rows of right join table
Select A.a, A.B, A.C, B.C, B.D, B.f from a right OUTER JOIN b on a.a = B.C
Full outer join includes not only matching rows for symbolic join tables, but also all records in two join tables
Select A.a, A.B, A.C, B.C, B.D, B.f from a full OUTER JOIN b on a.a = B.C
Partial SQL Server Content