Partial SQL Server Content

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.