Important SQL commands are enumerated

Source: Internet
Author: User
Tags create index

Important SQL Commands
    • SELECT -Extract data from the database
    • Update-Updates the data in the database
    • Delete-deletes data from the database
    • INSERT INTO-inserts new data into the database
    • CREATE database-creating new databases
    • alter database-Modify Databases
    • CREATE TABLE-Creates a new table
    • ALTER TABLE -Change (change) database table
    • Drop Table-delete tables
    • CREATE index-Creating indexes (search key)
    • Drop Index-delete indexes

Quick reference

SQL statements Grammar
and/or SELECT column_name (s)
From table_name
WHERE condition
And|or condition
ALTER TABLE ALTER TABLE table_name
ADD column_name datatype

Or

ALTER TABLE table_name
DROP COLUMN column_name

As (alias) SELECT column_name as Column_alias
From table_name

Or

SELECT column_name
From table_name as Table_alias

Between SELECT column_name (s)
From table_name
WHERE column_name
Between Value1 and value2
CREATE DATABASE CREATE DATABASE database_name
CREATE TABLE CREATE TABLE table_name
(
Column_name1 Data_type,
Column_name2 Data_type,
Column_name2 Data_type,
...
)
CREATE INDEX CREATE INDEX index_name
On table_name (COLUMN_NAME)

Or

CREATE UNIQUE INDEX index_name
On table_name (COLUMN_NAME)

CREATE VIEW CREATE VIEW View_name as
SELECT column_name (s)
From table_name
WHERE condition
DELETE DELETE from table_name
WHERE Some_column=some_value

Or

DELETE from table_name
(Note: deletes the entire table!!)

DELETE * FROM table_name
(Note: deletes the entire table!!)

DROP DATABASE DROP DATABASE database_name
DROP INDEX DROP INDEX table_name.index_name (SQL Server)
DROP INDEX index_name on table_name (MS Access)
DROP INDEX index_name (db2/oracle)
ALTER TABLE table_name
DROP INDEX index_name (MySQL)
DROP TABLE DROP TABLE table_name
GROUP by SELECT column_name, aggregate_function (column_name)
From table_name
WHERE column_name operator Value
GROUP by column_name
Having SELECT column_name, aggregate_function (column_name)
From table_name
WHERE column_name operator Value
GROUP by column_name
Having aggregate_function (column_name) operator value
Inch SELECT column_name (s)
From table_name
WHERE column_name
In (Value1,value2,..)
INSERT into INSERT into table_name
VALUES (value1, value2, Value3,....)

Or

INSERT into table_name
(Column1, Column2, Column3,...)
VALUES (value1, value2, Value3,....)

INNER JOIN SELECT column_name (s)
From table_name1
INNER JOIN table_name2
On Table_name1.column_name=table_name2.column_name
Left JOIN SELECT column_name (s)
From table_name1
Left JOIN table_name2
On Table_name1.column_name=table_name2.column_name
Right JOIN SELECT column_name (s)
From table_name1
Right JOIN table_name2
On Table_name1.column_name=table_name2.column_name
Full JOIN SELECT column_name (s)
From table_name1
Full JOIN table_name2
On Table_name1.column_name=table_name2.column_name
Like SELECT column_name (s)
From table_name
WHERE Column_namelike Pattern
ORDER by SELECT column_name (s)
From table_name
ORDER by column_name [asc| DESC]
SELECT SELECT column_name (s)
From table_name
SELECT * SELECT *
From table_name
SELECT DISTINCT SELECT DISTINCT column_name (s)
From table_name
SELECT into SELECT *
into new_table_name [in Externaldatabase]
From Old_table_name

Or

SELECT column_name (s)
into new_table_name [in Externaldatabase]
From Old_table_name

SELECT TOP SELECT TOP number|percent column_name (s)
From table_name
TRUNCATE TABLE TRUNCATE TABLE table_name
UNION SELECT column_name (s) from table_name1
UNION
SELECT column_name (s) from table_name2
UNION All SELECT column_name (s) from table_name1
UNION All
SELECT column_name (s) from table_name2
UPDATE UPDATE table_name
SET Column1=value, Column2=value,...
WHERE Some_column=some_value
WHERE SELECT column_name (s)
From table_name
WHERE column_name operator Value

Source://www.w3cschool.cn/sql/sql-quickref.html

Important SQL commands are enumerated

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.