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 数据库 Python
某站点存在SQL注入,直接可进行脱库(实战可参考此方法)
某站点存在SQL注入,直接可进行脱库(实战可参考此方法)
|
2月前
|
SQL 数据库
SQL error : “No query“问题参考
本文介绍了解决SQL中"No query"错误的步骤,包括错误提示、正确的SQL语句写法,以及更多相关参考信息。错误的原因是在构建更新语句时字段赋值之间缺少逗号,导致SQL解析失败。文章还提供了正确格式的SQL语句和相关错误处理的参考链接。
SQL error : “No query“问题参考
|
SQL 数据库 Python
某站点存在SQL注入,直接可进行脱库(实战可参考此方法)
首先选择需要扫描的站点,最简单粗暴的方法就是浏览器直接搜索,什么?不会?自行gu狗吧。
|
SQL 关系型数据库 MySQL
阿里云瑶池数据库SQL大赛获奖名单及参考答案
阿里云瑶池数据库SQL大赛获奖名单及参考答案
840 0
阿里云瑶池数据库SQL大赛获奖名单及参考答案
|
SQL 数据库
SQL数据库了解参考书籍学习
SQL数据库了解参考书籍学习
|
SQL 分布式计算 Cloud Native
带你读《企业级云原生白皮书项目实战》——5.2.4 SQL开发参考
带你读《企业级云原生白皮书项目实战》——5.2.4 SQL开发参考
138 0
|
SQL 关系型数据库 MySQL
MySQL | 适用SQL语法 快速参考(有例子,秒懂)
MySQL | 适用SQL语法 快速参考(有例子,秒懂)
204 0
MySQL | 适用SQL语法 快速参考(有例子,秒懂)
|
SQL XML JSON
【笔记】API参考—SQL审计—DisableSqlAudit
调用DisableSqlAudit接口关闭SQL审计功能。
|
SQL XML JSON
【笔记】API参考—SQL审计—DescribeSqlAuditInfo
调用DescribeSqlAuditInfo接口查看SQL审计信息。
|
SQL XML 存储
【笔记】API参考—SQL审计—EnableSqlAudit
调用EnableSqlAudit接口开启SQL审计功能。