SQL教程
  • [SQL教程]SQL 教程
  • [SQL教程]SQL 简介
  • [SQL教程]SQL 语法
  • [SQL教程]SQL SELECT 语句
  • [SQL教程]SQL SELECT DISTINCT 语句
  • [SQL教程]SQL WHERE 子句
  • [SQL教程]SQL AND & OR 运算符
  • [SQL教程]SQL ORDER BY 关键字
  • [SQL教程]SQL INSERT INTO 语句
  • [SQL教程]SQL UPDATE 语句
  • [SQL教程]SQL DELETE 语句
  • [SQL教程]SQL SELECT TOP, LIMIT, ROWNUM 子句
  • [SQL教程]SQL LIKE 操作符
  • [SQL教程]SQL 通配符
  • [SQL教程]SQL IN 操作符
  • [SQL教程]SQL BETWEEN 操作符
  • [SQL教程]SQL 别名
  • [SQL教程]SQL 连接(JOIN)
  • [SQL教程]SQL INNER JOIN 关键字
  • [SQL教程]SQL LEFT JOIN 关键字
  • [SQL教程]SQL RIGHT JOIN 关键字
  • [SQL教程]SQL FULL OUTER JOIN 关键字
  • [SQL教程]SQL UNION 操作符
  • [SQL教程]SQL SELECT INTO 语句
  • [SQL教程]SQL INSERT INTO SELECT 语句
  • [SQL教程]SQL CREATE DATABASE 语句
  • [SQL教程]SQL CREATE TABLE 语句
  • [SQL教程]SQL 约束 Constraints
  • [SQL教程]SQL NOT NULL 约束
  • [SQL教程]SQL UNIQUE 约束
  • [SQL教程]SQL PRIMARY KEY 约束
  • [SQL教程]SQL FOREIGN KEY 约束
  • [SQL教程]SQL CHECK 约束
  • [SQL教程]SQL DEFAULT 约束
  • [SQL教程]SQL CREATE INDEX 语句
  • [SQL教程]SQL 撤销索引、撤销表以及撤销数据库
  • [SQL教程]SQL ALTER TABLE 语句
  • [SQL教程]SQL AUTO INCREMENT 字段
  • [SQL教程]SQL 视图 Views
  • [SQL教程]SQL Date 函数
  • [SQL教程]SQL NULL 值
  • [SQL教程]SQL NULL 函数
  • [SQL教程]SQL 通用数据类型
  • [SQL教程]SQL 用于各种数据库的数据类型
  • [SQL教程]SQL 函数
  • [SQL教程]SQL AVG() 函数
  • [SQL教程]SQL COUNT() 函数
  • [SQL教程]SQL FIRST() 函数
  • [SQL教程]SQL LAST() 函数
  • [SQL教程]SQL MAX() 函数
  • [SQL教程]SQL MIN() Function
  • [SQL教程]SQL SUM() 函数
  • [SQL教程]SQL GROUP BY 语句
  • [SQL教程]SQL HAVING 子句
  • [SQL教程]SQL UCASE() 函数
  • [SQL教程]SQL LCASE() 函数
  • [SQL教程]SQL MID() 函数
  • [SQL教程]SQL LEN() 函数
  • [SQL教程]SQL ROUND() 函数
  • [SQL教程]SQL NOW() 函数
  • [SQL教程]SQL FORMAT() 函数
  • [SQL教程]SQL语句 快速参考
  • [SQL教程]SQL 主机
  • [SQL教程]SQL 总结
  • 直达腾讯云服务器
    腾讯云服务器,数据库,短信等热销产品限量秒杀;新购爆款3折起;
    腾讯云数据库MySQL入门机型仅12元/月
    腾讯云云服务器新购特惠,最低2折起,1核1G3年仅794.73元,即0.73元/日。
    腾讯云国际顶级CA机构SSL证书8.8折,云解析买一年最高送半年!
    腾讯云为数百万企业和开发者提供安全、稳定的云服务器、云数据库、CDN等云服务
    腾讯云服务器安全可靠高性能,多种配置供您选择
    腾讯云数据库性能卓越稳定可靠,为您解决数据库运维难题
    阿里云服务器入口
    180天免费用腾讯云服务器马上领取
    您当前位置:狗鱼MySQL教程 >> 数据库 >> SQL教程 >> SQL语句 快速参考
    SQL语句 快速参考
    更新日期: 2017年07月27日 来源: 本站原创 作者: 佚名 阅读:
    上一篇SQL FORMAT() 函数 下一篇:SQL 主机

    sql语句 快速参考


    SQL 语句 语法
    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

     
    IN 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_name LIKE 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

     


     

    感觉本站内容不错,读后有收获?

    我要小额赞助,鼓励提供更好的内容教程

    上一篇SQL FORMAT() 函数 下一篇:SQL 主机
    Copyright 2013-2017 Powered by 狗鱼MySQL教程,All Rights Reserved.
    广州相如计算机科技有限有限公司 版权所有 粤ICP备08130661号-4
    售前咨询:020-38667011 手机:13711588918