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
时间: 2024-12-28 17:13:36

SQL 快速参考的相关文章

sql快速参考

SQL 语句 语法 AND / OR SELECT column_name(s)FROM table_nameWHERE conditionAND|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_aliasFROM tab

SQL 语句快速参考

来自 W3CSchool 的 SQL 快速参考 SQL 语句 语法 AND / OR SELECT column_name(s)FROM table_nameWHERE conditionAND|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

Linux平台oracle 11g单实例 安装部署配置 快速参考

1.重建主机的Oracle用户 组 统一规范 uid gid 以保证共享存储挂接或其他需求的权限规范 userdel -r oracle groupadd -g 500 oinstall groupadd -g 501 dba useradd -g oinstall -G dba -u 500 oracle #id oracle uid=500(oracle) gid=500(oinstall) 组=500(oinstall),501(dba) 2.安装好Oracle 需要的rpm包.安装rpm

psql命令行快速参考

psql的命令语法是: psql [options] [dbname [username]] psql命令行选项以及它们的意思在表1-1中列出.使用以下命令可以看到psql完整的选项列表: $ psql --help 表1-1 psql命令行选项 选项 意义 -a 从脚本中响应所有输入 -A 取消表数据输出的对齐模式:功能与“-P format=unaligned”相同 -c <查询> 仅仅运行一个简单的查询(或者内部命令)然后退出 -d <数据库名> 指定连接到的数据库名(默认为

【转】Oracle中如何用一条SQL快速生成10万条测试数据

转自http://blog.csdn.net/welken/article/details/4971887 做数据库开发或管理的人经常要创建大量的测试数据,动不动就需要上万条,如果一条一条的录入,那会浪费大量的时间,本文介绍了Oracle中如何通过一条SQL快速生成大量的测试数据的方法. 产生测试数据的SQL如下: SQL> select rownum as id,  2                 to_char(sysdate + rownum / 24 / 3600, 'yyyy-mm

SED单行脚本快速参考(Unix 流编辑器)

------------------------------------------------------------------------- SED单行脚本快速参考(Unix 流编辑器) 2005年12月29日 英文标题:USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) 原标题:HANDY ONE-LINERS FOR SED (Unix stream editor) 整理:Eric Pement - 电邮:pemente[at]no

Apple Swift 中文教程 快速参考 基本语法 更新中...

总的来说,语法有java的味道,也有python的味道,还有swift自己的味道. 有些语法还是挺不伦不类的,不太好理解,即使你有几年的java或python经验,也不见得有些语法你能很轻松的看明白. 有些语法特性很好,很个性,但有些语法个人感觉乱,特性多,注意点多,还不太好理解. 慢慢学习吧... ================================================================= 值类型 Int Double Bool String 用双引号"&

【翻译】C#和.NET核心快速参考

原文:[翻译]C#和.NET核心快速参考 PS:在网上看到的一篇C#总结,英文的,总结的还可以,都是基础知识,翻译给大家学习.文章结尾有英文原版.发布地址:http://www.cnblogs.com/zxlovenet/p/3745903.html 1.数据类型 类型名 大小 示例 String 2字节/字符 S="reference"; Bool b=true; char 2字节 ch='a'; byte 1字节 b=0x78; short 2字节 lval=54; int 4字节

使用C#+Linq+SQL快速开发业务

C#开发桌面程序的效率确实很高,今天就来总结下如何使用C#+Linq+SQL快速开发一个新的业务系统. Linq是微软官方的轻量级的ORM工具,使用它结合SQL可以快速的生成实体类,再通过Linq操作可以快速的开发业务.   1.生成实体类: 对于已经存在的数据库结构(SQL Server),可以使用VS自带的命令行工具生成实体类:     sqlmetal工具可以用来对SQL Server数据库快速生成C#中的实体类,具体参数: /server参数指定服务器名称 /database参数指定数据