• 新希望!中超19岁新星半年增重十斤 曾戏耍恒大两国脚 2018-10-17
  • 迎丰收 晒丰收 庆丰收 2018-10-15
  • “捂脸表情”被注册成商标?申请人不认为商标侵权 2018-10-15
  • 战巡南海、绕岛巡航…空军有“飞出去”的主心骨 2018-10-14
  • 幼儿园要求家长写一万字读后感:不能这样玩家长|幼儿园|家长-教育时讯 2018-10-13
  • 中国故宫文物展在希腊举行 2018-10-13
  • 車·晓 第26期 車企官方降价真相幾何? 2018-10-12
  • 宝沃总裁杨嵩:曾和奔驰宝马同水平 已不能同日而语 2018-10-11
  • 新时代党员干部要有更大的担当和作为 2018-10-10
  • “2018-雷霆”专项行动破获百余起台湾间谍案 2018-10-09
  • 朝韩首脑今起在平壤会晤 “金文会”将聚焦三大议题 2018-10-09
  • 2018顺义啤酒节--北京频道--人民网 2018-10-08
  • 台湾遭遇的“断交潮”有无化解之道? 2018-10-08
  • 习近平会见爱沙尼亚总统卡柳莱德 2018-10-08
  • 中国空间站研制建设正有序开展 坚持和平利用 2018-10-07
  • 【sql教程】来自 W3CSchool 的 SQL 快速参考

    栏目: SQL 发布于: 2014-11-27 11:47:21

    来自 W3CSchool 的 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

    来源:http://www.rocksun.cn/sql/sql-quickref.html



    本文转载自:w3cschool
    本站文章除注明转载外,均为本站原创或编译?;队魏涡问降淖?,但请务必注明出处。
    转载请注明:文章转载自 七星彩票平台
    本文标题:【sql教程】来自 W3CSchool 的 SQL 快速参考
    IT技术书籍推荐:
    深入PHP:面向对象、模式与实践(第3版)
    深入PHP:面向对象、模式与实践(第3版)
    Mart Zandstra (作者), 陈浩 (译者), 吴孙滨 (译者), 胡丹 (译者), 李静 (译者)
    《深入PHP:面向对象、模式与实践(第3版)》是PHP专家经典力作的最新版本。书中主要介绍了如何使用面向对象技术和设计模式编写稳定的、可维护的代码,如何使用Subversion管理多个开发人员,如何使用Phing和PEAR进行构建和安装,以及将构建和测试过程自动化的策略,包括持续集成?!渡钊隤HP:面向对象、模式与实践(第3版)》适合中高级PHP程序员阅读。