SQL(Structured Query Language)是一种用于访问和处理数据库的标准语言。它可以用来查询、更新和管理数据库中的数据。SQL快速参考手册是一本关于SQL语言的参考书,它包含了SQL语言的所有基本知识,以及如何使用它来进行数据库开发。
SQL快速参考手册主要包含以下内容:
1. SQL 基础知识:包括 SQL 语法、数据类型、表达式、函数、子查询等。 2. 数据库对象:包括表、视图、存储过程、函数、触发器等。 3. 数据库开发:包括创建表、删除表、修改表结构、创建存储过程、创建函数以及使用 SQL 语句进行 CRUD 操作。 4. 数据库优化:包含如何优化 SQL 语句以及如何使用合适的索引来加快 SQL 执行速度。 5. 常用命令:包含常用的 SQL 命令如 SELECT 、 INSERT 、 UPDATE 等。
此外,SQL快速参考手册还会介绍一些常用的工具,例如 MySQL Workbench 和 phpMyAdmin 等工具的使用方法。此外,书中还会有一些实例代码来帮助读者理解并学习 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 |
AS (alias) | SELECT column_name AS column_alias FROM table_name or SELECT column_name |
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 |
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 DELETE * FROM table_name |
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 |
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) |
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 |
来源://www..cn/sql/sql-quickref.html
如果我们需要修改或更新MySQL中的数据,我们可以使用 SQL UPDATE 命令来操作。.语法以下是 UPDATE 命令修改 MySQL 数据表数据的...
截取字符串用法:substr(string string,num start,num length);select substr(参数1,参数2,参数3) from 表名st...
MySQL中删除数据表是非常容易操作的, 但是你再进行删除表操作时要非常小心,因为执行删除命令后所有数据都会消失。 语法 以下为...
MySQL Date 函数定义和用法 NOW() 返回当前的日期和时间。 语法NOW()实例 下面是 SELECT 语句:SELECT NOW(),CURDATE(),CURTIME(...
MySQL Date 函数定义和用法 EXTRACT() 函数用于返回日期/时间的单独部分,比如年、月、日、小时、分钟等等。 语法EXTRACT(unit F...