SQL Format notes

Source: Internet
Author: User

Description: the parameters within [] can be omitted

Creation of tables

Create Table < table name > (< column name >< data type >[ column-Level integrity constraints  ],< column name >< data type >[ column-level integrity constraint conditions ], ...,< table-level integrity constraints >);

Changes to the table

Alter Table <Table name>[Add [Column] <New Column Name> <Data type> [Integrity Constraints]][Add < table-level integrity constraints >][Drop [Column] <Column Name> [cascade|restrict]][drop constraint < integrity constraint name > [Restrict|cascade]][ALTER COLUMN < column name > < data type >];

Deletion of tables

Drop Table < table name >[cascade|restrict];

Inquire

Select < target column expression >[,< target column expression >] • •  from < table name >[GROUP by < column name 1> [having < conditional expression >]]     -- Grouping [ORDER by < column name 2> [Asc|desc]]             -- Ascending or Descending

Find matching lookup for like

where < column Name 1>[not]like[escape ' < transcoding character > ' ]

% (Percent semicolon) represents a string of any length (length can be 0)

_ (lower line) represents any single character

Inserting data

Insert  into < table name >[(< attribute column 1> [,< property column 2>]values (< constant 1>[,< constant 2> ]);

Insert subquery Results

Insert  into < table name >[(< attribute column 1> [,< property column 2> ])]Select< target column expression 1>[,< target column expression 2> ]···  from < table name >  - sub-query results

modifying data

Update < table name >set< column name >=< expression >[,< column Name] >=< expression > ][where < conditions >];

Delete data

Delete  from < table name >[where < condition >];

SQL Format notes

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.