MySQL开发者SQL权威指南-附录

更新时间:2023-05-24 02:44:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

MySQL开发者SQL权威指南的附录文档

附录A SQL语法

A.1 简介

在这个附录中,我们介绍用来定义语句的范式方法,给出了本书中讨论的SQL语句的定义,并且列出了保留字。这个附录中的定义可能和前面章节中的内容有所不同。出现这种情况的主要原因是,在那些章节中,我们一步一步地讲解了语句和概念,为了避免涉及过多的细节,有时候使用了定义的简单版本。本附录则包含完整的定义。

A.2 BNF范式

在这个附录以及整本书中,我们都使用了一种形式化表示方法来描述所有SQL语句和常用元素的语法。这种表示由巴科斯范式(Backus Naur Form,BNF)衍生而来,BNF的命名就是为了纪念John Backus和Peter Naur Form。我们使用的元符号的意义基于SQL标准中的元符号之上。

BNF采用了一种具有替换规则和生成规则的语言,该语言由一系列的符号组成。每个生成规则定义了一个符号。一个符号可能是一条SQL语句、一个表名或者一个冒号。终结符(terminalsymbol)是一种特殊类型的符号。除了终结符以外的所有其他的符号,都根据一条生成规则中的其他符号来定义。终结符的例子是单词CLOSE和分号。

我们可以把一个生成规则和一个元素的定义进行比较,其中,该元素的定义用到了其他地方定义的元素。在这个例子中,一个元素就等于一个符号。

如下的元符号并没有构成SQL语言的一部分,但是也属于范式技术:

< >::=|[ ]...{ };"

现在,我们来说明这些符号的含义。

< >符号

尖括号(<>)表示非终结符。对于每一个非终结符都存在一个生成规则。我们用小写字母来表示非终结符的名字。非终结符的两个例子就是<select statement> 和<table reference>。

::=符号

::=符号用在一个生成规则中,把一个定义的非终结符(位于::=符号的左边)和它的定义(位于::=符号的右边)分隔开来。::=符号应该读作“定义为”。参见下面的CLOSE CURSOR语句的生成规则:

<close cursor statement> ::= CLOSE <cursor name>

MySQL开发者SQL权威指南的附录文档

598附录

说明:CLOSE CURSOR语句由结束标记和跟在后面的一个非终结符游标名组成。<cursorname>也应该有一个生成规则。

|符号

|符号表示可替代选择。下面给出元素<character>的一个生成规则:

<character> ::= <digit> | <letter> | <special symbol> | ''

说明:我们可以得出结论,这个符号是一个数字、一个字母、一个特殊符号或者两个双引号,它必为四者之一。[和]符号

放入到方括号([ ])中的内容都可能被使用。下面是ROLLBACK语句的生成规则:

<rollback statement> ::= ROLLBACK [ WORK ]

说明:一条ROLLBACK语句总是由单词ROLLBACK组成,后面可选地跟着单词WORK。...符号

三个点号表示可能重复一次或多次的内容。下面是一个整数的生成规则的例子:

<whole number> ::= <digit>...

说明:一个整数包含一系列的数字(最少一个)

把3个点号和方括号组合起来,我们就能够表示可能出现0次、一次或多次的某一个元素:

<from clause> ::=

FROM <table reference> [ , <table reference> ]...

说明:一个FROM子句以一个终结符FROM开始,并且后面至少跟着一个表引用。这个表引用的后面可能跟着元素的一个列表,其中每个元素由一个逗号和跟在后面的一个表引用组成。别忘了,逗号是SQL的一部分而不是范式的一部分。{和}符号

位于花括号({ })之间的所有符号都形成一个组。例如,和|符号一起使用的花括号明确地表示了替换选择是什么。下面的例子是浮点直接量的生成规则的一部分。

<float literal> ::=

<mantissa> { E | e } <exponent>

说明:浮点直接量以一个尾数开始而以一个指数结束。在这之间,我们可以使用一个大写字母E或者小写字母e,必须使用其中一个。

如果我们把花括号和三个点号组合起来,则可以表示应该出现一次或多次的一个元素。在生成规则A { B }...中,这意味着我们必须首先使用元素A,然后应该跟着一个或多个B元素。

;符号

某些符号有相同的定义。我们可以使用分号来缩短定义,而不是重复它们。下面的定义

<character literal> ;<varchar literal> ;

<long varchar literal> ::= <character string>

MySQL开发者SQL权威指南的附录文档

分别等同于如下的3个定义:

<character literal> ::= <character string><varchar literal> ::= <character string><long varchar literal> ::= <character string>

"符号

少数几个元符号,如"符号,是特殊SQL语句本身的一部分。为了避免混淆,这些符号用一个双引号符号表示。另外,这意味着用于SQL中的符号"在生成规则中表示为"""。

其他注意事项

任何以大写字母出现的内容,只要符号不是表示法的一部分,必须不做改变地采用。 生成规则的右边部分的符号的顺序是固定的。

生成规则中的空白没有意义。通常,添加它们是为了让规则更加可读。因此,如下的两个生成规则的含义是相同的:

<alphanumeric literal> ::= ' [ <character>... ] '

<alphanumeric literal> ::= '[<character>...]'

A.3 SQL中的保留字

MySQL支持所谓的保留字或关键字,如SELECT和CREATE。在MySQL中,这些保留字不能用作数据库对象(如表、列、视图和用户)的名字。下面的列表包含了SQL3标准中定义的保留字,后面的是MySQL自己的保留字列表。

ABSOLUTE, ACTION, ADD, ALL, ALLOCATE, ALTER, AND, ANY, ARE, AS, ASC,ASSERTION, AT, AUTHORIZATION, AVG

BEGIN, BETWEEN, BIT, BIT_LENGTH, BOTH, BY

CASCADE, CASCADED, CASE, CAST, CATALOG, CHAR, CHARACTER, CHAR_LENGTH,CHARACTER_LENGTH, CHECK, CLOSE, COALESCE, COLLATE, COLLATION, COLUMN, COMMIT,CONNECT, CONNECTION, CONSTRAINT, CONSTRAINTS, CONTINUE, CONVERT,CORRESPONDING, COUNT, CREATE, CROSS, CURRENT, CURRENT_DATE, CURRENT_TIME,CURRENT_TIMESTAMP, CURRENT_USER, CURSOR

DATE, DAY, DEALLOCATE, DEC, DECIMAL, DECLARE, DEFAULT, DEFERRABLE, DEFERRED,DELETE, DESC, DESCRIBE, DESCRIPTOR, DIAGNOSTICS, DISCONNECT, DISTINCT, DOMAIN,DOUBLE, DROP

ELSE, END, END-EXEC, ESCAPE, EXCEPT, EXCEPTION, EXEC, EXECUTE, EXISTS,EXTERNAL, EXTRACT

FALSE, FETCH, FIRST, FLOAT, FOR, FOREIGN, FOUND, FROM, FULL GET, GLOBAL, GO, GOTO, GRANT, GROUP HAVING, HOUR

IDENTITY, IMMEDIATE, IN, INDICATOR, INITIALLY, INNER, INPUT, INSENSITIVE,INSERT, INT, INTEGER, INTERSECT, INTERVAL, INTO, IS, ISOLATION JOIN KEY

MySQL开发者SQL权威指南的附录文档

600附录

LANGUAGE, LAST, LEADING, LEFT, LEVEL, LIKE, LOCAL, LOWER MATCH, MAX, MIN, MINUTE, MODULE, MONTH

NAMES, NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULL, NULLIF, NUMERIC

OCTET_LENGTH, OF, ON, ONLY, OPEN, OPTION, OR, ORDER, OUTER, OUTPUT, OVERLAPS PARTIAL, POSITION, PRECISION, PREPARE, PRESERVE, PRIMARY, PRIOR, PRIVILEGES,PROCEDURE, PUBLIC

READ, REAL, REFERENCES, RELATIVE, RESTRICT, REVOKE, RIGHT, ROLLBACK, ROWS

SCHEMA, SCROLL, SECOND, SECTION, SELECT, SESSION, SESSION_USER, SET, SIZE,SMALLINT, SOME, SQL, SQLCODE, SQLERROR, SQLSTATE, SUBSTRING, SUM, SYSTEM_USER TABLE, TEMPORARY, THEN, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE, TO,TRAILING, TRANSACTION, TRANSLATE, TRANSLATION, TRIM, TRUE UNION, UNIQUE, UNKNOWN, UPDATE, UPPER, USAGE, USER, USING VALUE, VALUES, VARCHAR, VARYING, VIEW WHEN, WHENEVER, WHERE, WITH, WORK, WRITE YEAR ZONE

这个列表是MySQL中保留字的列表。前面的列表中已经出现过的单词在这里省略掉了。 ANALYZE, ASENSITIVE

BEFORE, BIGINT, BINARY, BLOB CALL, CHANGE, CONDITION

DATABASE, DATABASES, DAY_HOUR, DAY_MICROSECOND, DAY_MINUTE,DAY_SECOND,DELAYED, DETERMINISTIC, DISTINCTROW, DIV, DUAL EACH, ELSEIF, ENCLOSED, ESCAPED, EXIT, EXPLAIN FLOAT4, FLOAT8, FORCE, FULLTEXT

HIGH_PRIORITY, HOUR_MICROSECOND, HOUR_MINUTE, HOUR_SECOND

IF, IGNORE, INDEX, INFILE, INOUT, INT1, INT2, INT3, INT4, INT8, ITERATE KEYS, KILL

LABEL, LEAVE, LIMIT, LINES, LOAD, LOCALTIME, LOCALTIMESTAMP, LOCK, LONG,LONGBLOB, LONGTEXT, LOOP, LOW_PRIORITY

MEDIUMBLOB, MEDIUMINT, MEDIUMTEXT, MIDDLEINT, MINUTE_MICROSECOND,MINUTE_SECOND, MOD, MODIFIES NO_WRITE_TO_BINLOG

OPTIMIZE, OPTIONALLY, OUT, OUTFILE PURGE

RAID0, READS, REGEXP, RELEASE, RENAME, REPEAT, REPLACE, REQUIRE, RETURN, RLIKE SCHEMAS, SECOND_MICROSECOND, SENSITIVE, SEPARATOR, SHOW, SONAME, SPATIAL,SPECIFIC, SQLEXCEPTION, SQLWARNING, SQL_BIG_RESULT, SQL_CALC_FOUND_ROWS,SQL_SMALL_RESULT, SSL, STARTING, STRAIGHT_JOIN TERMINATED, TINYBLOB, TINYINT, TINYTEXT, TRIGGER

UNDO, UNLOCK, UNSIGNED, USE, UTC_DATE, UTC_TIME, UTC_TIMESTAMP

MySQL开发者SQL权威指南的附录文档

VARBINARY, VARCHARACTER WHILE

X509, XOR YEAR_MONTH ZEROFILL

我们强烈建议你在为数据库对象选取名字的时候遵守以下的建议: 避免单字母单词,即便单字母单词并没有出现在保留字列表中。

避免可能被视为列表中单词缩写的单词,例如,不要使用DATA,因为单词DATABASE出现在了列表中。

避免使用列表中单词的派生词,例如,复数形式或动词形式。因此,不要使用CURSORS(CURSOR的复数)或ORDERING(动词ORDER的现在分词)。

A.4 SQL语句的语法定义

本节包含了本书中所描述的所有SQL语句的定义。几条语句使用了某些通用的元素,例如条件和列列表。如果一个元素只属于一条语句,那么它和该语句一起包含在A.4.2节中。所有其他的语句都在A.4.3节介绍。我们首先从SQL语句的不同组开始。

A.4.1 SQL语句的分组

4.15节提到了SQL语句的集合可以划分为组,例如DDL、DML和DCL语句。在本节中,我们说明了每条语句分别属于哪个组。

SQL语句

<sql statement> ::=

<declarative statement> |<procedural statement> |<informative statement> |<table maintenance statement>

Declarative语句

<declarative statement> ::=

<ddl statement> |<dml statement> |<dcl statement>

DDL语句

<ddl statement> ::=

<alter database statement> |<alter event statement> |<alter function statement> |<alter procedure statement> |<alter table statement> |<create database statement> |<create event statement> |<create function statement> |

MySQL开发者SQL权威指南的附录文档

602附录

<create index statement> |<create procedure statement> |<create sequence statement> |<create table statement> |<create trigger statement> |<create view statement> |<drop database statement> |<drop event statement> |<drop function statement> |<drop index statement> |<drop procedure statement> |<drop table statement> |<drop trigger statement> |<drop view statement> |<rename table statement>

DML语句

<dml statement> ::=

<begin work statement> |<call statement> |<close cursor statement> |<commit statement> |<deallocate prepare statement> |<delete statement> |<do statement> |<execute statement> |<fetch cursor statement> |<handler close statement> |<handler open statement> |<handler read statement> |<insert statement> |<load statement> |<lock table statement> |<open cursor statement> |<prepare statement> |<replace statement> |<rollback statement> |<savepoint statement> |<select statement> |<select into statement> |<set statement> |<set transaction statement> |<start transaction statement> |<truncate table statement> |<unlock table statement> |<update statement>

MySQL开发者SQL权威指南的附录文档

DCL语句

<dcl statement> ::=

<alter user statement> |<create user statement> |<drop user statement> |<grant statement> |<rename user statement> |<set password statement> |<revoke statement>

Procedural语句

<procedural statement> ::=

<begin-end block> |<call statement> |<declare condition statement> |<declare cursor statement> |<declare handler statement> |<declare variable statement> |<flow control statement> |<return statement>

Flow-Control语句

<flow control statement> ::=

<case statement> |<if statement> |<iterate statement> |<leave statement> |<loop statement> |<repeat statement> |<while statement>

Informative语句

<informative statement> ::=

<describe statement> |<help statement> |<show statement>

Table Maintenance语句

<table maintenance statement> ::=

<analyze table statement> |<backup table statement> |<checksum table statement> |<check table statement> |<optimize table statement> |<repair table statement> |<restore table statement>

MySQL开发者SQL权威指南的附录文档

604附录

A.4.2 SQL语句的定义

Alter Database语句

<alter database statement> ::=

ALTER DATABASE [ <database name> ]

[ <database option>... ]

Alter Event语句

<alter event statement> ::=

ALTER EVENT [ <database name> . ] <event name>

ON SCHEDULE <event schedule>[ RENAME TO <event name> ]

[ ON COMPLETION [ NOT ] PRESERVE ][ ENABLE | DISABLE ]

[ COMMENT <alphanumeric literal> ]DO <sql statement>

Alter Function语句

<alter function statement> ::=

ALTER FUNCTION [ <database name> . ] <stored function name>

[ <routine characteristic>... ]

Alter Procedure语句

<alter procedure statement> ::=

ALTER PROCEDURE [ <database name> . ] <stored procedure name>

[ <routine characteristic>... ]

Alter Table Statement

<alter table statement> ::=

ALTER [ IGNORE ] TABLE <table specification>

<table structure change>

Alter View语句

<alter view statement> ::=

ALTER

[ <definer option> ]

[ <sql security option> ]

[ ALGORITHM = { MERGE | TEMPTABLE UNDEFINED } ]

VIEW <view name> [ <column list> ] AS<table expression>[ WITH [ CASCADED | LOCAL ] CHECK OPTION ]

Analyze Table语句

<analyze table statement> ::=

ANALYZE [ <analyze option> ]

TABLE <table specification> [ , <table specification> ]...<analyze option> ::= NO_WRITE_TO_BINLOG | LOCAL

MySQL开发者SQL权威指南的附录文档

Backup Table语句

<backup table statement> ::=

BACKUP TABLE <table specification>

[ , <table specification> ]...TO <directory>

Begin Work语句

<begin work statement> ::=

BEGIN WORK

Call语句

<call statement> ::=

CALL [ <database name> . ] <stored procedure name>

( [ <scalar expression> [ , <scalar expression> ]... ] )

Case语句

<case statement> ::=

{ CASE <scalar expression>

WHEN <scalar expression> THEN <statemen list>

[ WHEN <scalar expression> THE <statement list> ]...[ ELSE <statement list> ]END CASE } |{ CASE

WHEN <condition> THEN <statement list>

[ WHEN <condition> THEN <statement list>]...[ ELSE <statement list>END CASE }

Checksum Table语句

<checksum table statement> ::=

CHECKSUM TABLE <table specification>

[ , <table specification> ]...[ <checksum option> ]<checksum option> ::= QUICK | EXTENDED

Check Table语句

<check table statement> ::=

CHECK TABLE <table specification> [ <tablespecification> ]...

[ <check option> ]...<check option> ::=

FOR UPGRADE | QUICK | FAST | MEDIUM EXTENDED | CHANGED

Close Cursor语句

<close cursor statement> ::=

CLOSE <cursor name>

MySQL开发者SQL权威指南的附录文档

606附录

Commit语句

<commit statement> ::=

COMMIT [ WORK ] [ AND [ NO ] CHAIN ] [ [ NO ] RELEASE ]

Create Database语句

<create database statement> ::=

CREATE DATABASE [ IF NOT EXISTS ] <database name>

[ <database option>... ]

Create Event语句

<create event statement> ::=

CREATE EVENT [ IF NOT EXISTS ]

[ <database name> . ] <event name>ON SCHEDULE <event schedule>[ ON COMPLETION [ NOT ] PRESERVE ][ ENABLE | DISABLE ]

[ COMMENT <alphanumeric literal> ]DO <event action>

<event action> ::=

<declarative sql statement> |<begin-end block>

Create Function语句

<create function statement> ::=

CREATE [ <definer option> ]

FUNCTION [ <database name> . ] <stored function name>( [ <parameter list> ] )RETURNS <data type>

[ <routine characteristic>... ]<routine body>

Create Index语句

<create index statement> ::=

CREATE [ <index type> ] INDEX <index name>[ USING { BTREE | HASH } ]ON <table specification>

( <column in index> [ , <column in index> ]... )

Create Procedure语句

<create procedure statement> ::=

CREATE [<definer option> ]

PROCEDURE <stored procedure name> ( [<parameter list> ] )[ <routine characteristic>... ]<routine body>

MySQL开发者SQL权威指南的附录文档

Create Table语句

<create table statement> ::=

CREATE [ TEMPORARY ] TABLE [ IF NOT EXISTS ]

<table specification><table structure>

[ <table option>... ]

Create Trigger语句

<create trigger statement> ::=

CREATE[ <definer option> ]

TRIGGER <trigger name><trigger moment><trigger event><trigger action><trigger moment> ::= BEFORE | AFTER<trigger event> ::=

{ INSERT | DELETE | UPDATE }

ON <table specification>FOR EACH ROW<trigger action> ::= <sql statement>

Create User语句

<create user statement> ::=

CREATE USER<user specification>

[ , <user specification> ]...

<user specification> ::=

<user name> [ IDENTIFIED BY [ PASSWORD ]<password> ]

Create View语句

<create view statement> ::=

CREATE [ OR REPLACE ]

[ <definer option> ]

[ <sql security option> ]

[ ALGORITHM = { MERGE | TEMPTABLE UNDEFINED } ]

VIEW <view name> [ <column list> ] AS<table expression>[ WITH [ CASCADED | LOCAL ] CHECK OPTION ]

Deallocate Prepare语句

<deallocate prepare statement> ::=

{ DEALLOCATE | DROP } PREPARE <statement name>

Declare Condition语句

<declare condition statement> ::=

MySQL开发者SQL权威指南的附录文档

608附录

DECLARE <condition name> CONDITION FOR

{ SQLSTATE [ VALUE ] <sqlstate value> } |<mysql error code>

Declare Cursor语句

<declare cursor statement> ::=

DECLARE<cursor name> CURSOR FOR <table expression>

Declare Handler语句

<declare handler statement> ::=

DECLARE <handler type> HANDLER FOR <condition value list>

<procedural statement><handler type> ::=

CONTINUE |EXIT |UNDO

<condition value list> ::=

<condition value> [ , <condition value> ]...<condition value> ::=

SQLSTATE [ VALUE ] <sqlstate value> |<mysql error code> |SQLWARNING |NOT FOUND |SQLEXCEPTION |<condition name>

Declare Variable语句

<declare variable statement> ::=

DECLARE <variable list> <data type>

[ DEFAULT <scalar expression> ]

Delete语句

为了避免不必要的重复定义,这里给出DELETE语句的两个定义。第一个定义从一个表中删除行;第二个定义同时从多个表中删除行。

<delete statement> ::=

DELETE [ IGNORE ]

FROM <table reference>[ <where clause> ][ <order by clause> ][ <limit clause> ]

<delete statement> ::=

{ DELETE [ LOW_PRIORITY ] [ IGNORE ]

<table reference> [ , <table reference> ]...

FROM <table reference> [ , <table reference >]...

MySQL开发者SQL权威指南的附录文档

[ <where clause> ] } |

{ DELETE [ LOW_PRIORITY ] [ IGNORE ]

FROM <table reference> [ , <table reference> ]ING <table reference> [ , <table reference> ]...[ <where clause> ] }

Describe语句

<describe statement> ::=

{ DESCRIBE | DESC } <table specification>

[ <column name> | <alphanumeric literal> ]

Do语句

<do statement> ::=

DO <scalar expression>

[ , <scalar expression> ]...

Drop Database语句

<drop database statement> ::=

DROP DATABASE [ IF NOT EXISTS ] <database name>

Drop Event语句

<drop event statement> ::=

DROP EVENT [ IF EXISTS ] [ <database name> .] <event name>

Drop Function语句

<drop function statement> ::=

DROP FUNCTION [ IF EXISTS ]

[ <database name> . ] <stored function name>

Drop Index语句

<drop index statement> ::=

DROP INDEX <index name> ON <table specification>

Drop Procedure语句

<drop procedure statement> ::=

DROP PROCEDURE [ IF EXISTS ]

[ <database name> . ] <stored procedure name>

Drop Table语句

<drop table statement> ::=

DROP [ TEMPORARY ] { TABLE | TABLES } [ IF EXISTS ]

<table specification> [ , <table specification> ]...[ CASCADE | RESTRICT ]

Drop Trigger语句

<drop trigger statement> ::=

DROP TRIGGER [ <table name> . ] <trigger name>

MySQL开发者SQL权威指南的附录文档

610附录

Drop User语句

<drop user statement> ::=

DROP USER <user name> [ , <user name> ]...

Drop View语句

<drop view statement> ::=

DROP VIEW [ IF EXISTS ] <table specification>

[ , <table specification> ]...[ RESTRICT | CASCADE ]

Execute语句

<execute statement> ::=

EXECUTE <statement name>

[ USING <user variable> [ , <user variable>]... ]

Fetch Cursor语句

<fetch cursor statement> ::=

FETCH <cursor name>

INTO <local variable> [ , <local variable> ]...

Grant语句

<grant statement> ::=

<grant table privilege statement> |<grant database privilege statement> |<grant user privilege statement> |<grant execute privilege statement><grant table privilege statement> ::=

GRANT <table privileges>ON <table specification>TO <grantees>

[ WITH <grant option>... ]<grant database privilege statement> ::=

GRANT <database privileges>ON [ <database name> . ] *TO <grantees>

[ WITH <grant option>... ]<grant user privilege statement> ::=

GRANT <user privileges>ON *.*

TO <grantees>

[ WITH <grant option>... ]<grant execute privilege statement> ::=

GRANT EXECUTE

MySQL开发者SQL权威指南的附录文档

ON { PROCEDURE <stored procedure name> |

FUNCTION <stored function name> }

TO <grantees>

[ WITH <grant option>... ]

Handler Close语句

<handler close statement> ::=

HANDLER <handler name> CLOSE

Handler Open语句

<handler open statement> ::=

HANDLER <table specification> OPEN [ As <handler name> ]

Handler Read语句

<handler read statement> ::=

HANDLER <handler name> READ <read specification>

[ <where clause> ][ <limit clause> ]

<read specification> ::=

FIRST |NEXT |{ <index name> { FIRST | NEXT | PREV | LAST } } |{ <index name> { = | > | >= | <= | < }

<scalar expression list> }

Help语句

<help statement> ::=

HELP <alphanumeric literal>

If语句

<if statement> ::=

IF <condition> THEN <statement list>

[ ELSEIF <condition> THEN <statement list>]...[ ELSE <statement list> ]END IF

Insert语句

<insert statement> ::=

INSERT [ DELAYED | LOW_PRIORITY | HIGH_PRIORITY ]

[ IGNORE ] [ INTO ] <table specification>

<insert specification> [ <on duplicate key specification> ]

<on duplicate key specification> ::=

ON DUPLICATE KEY UPDATE <column assignment>

[ , <column assignment> ]...

MySQL开发者SQL权威指南的附录文档

612附录

Iterate语句

<iterate statement> ::=

ITERATE <label>

Leave语句

<leave statement> ::=

LEAVE <label>

Load语句

<load statement> ::=

LOAD DATA [ LOW_PRIORITY ] [ CONCURRENT ] [ LOCAL ]

INFILE '<file name>'[ REPLACE | IGNORE ]

INTO TABLE <table specification>[ <fields specification> ][ <lines specification> ]

[ IGNORE <whole number> LINES ]

[ { <column name> | <user variable> }

[ , { <column name> | <user variable> } ]... ][ <set statement> ]

<fields specification> ::=

FIELDS [ TERMINATED BY <alphanumeric literal> ]

[ [ OPTIONALLY ] ENCLOSED BY <alphanumeric literal> ][ ESCAPED BY <alphanumeric literal> ]<lines specification> ::=

LINES [ TERMINATED BY <alphanumeric literal> ]

[ STARTING BY <alphanumeric literal> ]

Lock Table语句

<lock table statement> ::=

LOCK { TABLE | TABLES } <lock table> [ ,<lock table> ]...<lock table> ::=

<table specification> [ AS <pseudonym> ]<lock type><lock type> ::= READ | READ LOCAL | WRITE |LOW_PRIORITY WRITE

Loop语句

<loop statement> ::=

[ <label> : ] LOOP <statement list>END LOOP [ <label> ]

Open Cursor语句

<open cursor statement> ::=

OPEN <cursor name>

MySQL开发者SQL权威指南的附录文档

Optimize Table语句

<optimize table statement> ::=

OPTIMIZE [ <optimize option> ]

TABLE <table specification> [ , <table specification> ]...<optimize option> ::= NO_WRITE_TO_BINLOG | LOCAL

Prepare语句

<prepare statement> ::=

PREPARE <statement name>

FROM { <alphanumeric literal> | <user variable> }

Rename Table语句

<rename table statement> ::=

RENAME { TABLE | TABLES } <table name change>

[ , <table name change> ]...<table name change> ::= <table name> TO <table name>

Rename User语句

<rename user statement> ::=

RENAME USER <user name> TO <user name>

[ , <user name> TO <user name> ]...

Repair Table语句

<repair table statement> ::=

REPAIR [ <repair option> ]

TABLE <table specification> [ , <table specification> ]...[ QUICK ] [ EXTENDED ] [ USE_FRM ]<repair option> ::= NO_WRITE_TO_BINLOG | LOCAL

Repeat语句

<repeat statement> ::=

[ <label> : ] REPEAT <statement list>UNTIL <condition>END REPEAT <label>

Replace语句

<replace statement> ::=

REPLACE [ DELAYED | LOW_PRIORITY] [ IGNORE ][ IGNORE ] [ INTO ] <table specification><insert specification>

Restore Table语句

<restore table statement> ::=

RESTORE TABLE <table specification>

MySQL开发者SQL权威指南的附录文档

614附录

[ , <table specification> ]...FROM <directory>

Return语句

<return statement> ::=

RETURN <scalar expression>

Revoke语句

<revoke statement> ::=

<revoke table privilege statement> |<revoke database privilege statement> |<revoke user privilege statement> |<revoke execute privilege statement> |<revoke event privilege statement>

<revoke table privilege statement> ::=

REVOKE [ <table privileges> ] [ GRANT OPTION ]ON <table specification>

FROM <user name> [ , <user name> ]...<revoke database privilege statement> ::=

REVOKE [ <database privileges> ] [ GRANT OPTION ]ON [ <database name> . ] *

FROM <user name> [ , <user name> ]...<revoke user privilege statement> ::=

REVOKE [ <user privileges> ] [ GRANT OPTION ]ON *.*

FROM <user name> [ , <user name> ]...<revoke execute privilege statement> ::=

REVOKE EXECUTE

ON { PROCEDURE <stored procedure name> |

FUNCTION <stored function name> }

FROM <grantees><revoke event privilege statement> ::=

REVOKE EVENT

ON [ <database name> . | *. ] *FROM <grantees>

Rollback语句

<rollback statement> ::=

ROLLBACK [ WORK ] [ AND [ NO ] CHAIN ] [ [ NO ] RELEASE ][ TO SAVEPOINT <savepoint name> ]

Savepoint语句

<savepoint statement> ::=

MySQL开发者SQL权威指南的附录文档

SAVEPOINT <savepoint name>

Select语句

<select statement> ::=

<table expression>[ <into file clause> ]

[ FOR UPDATE | LOCK IN SHARE MODE ]

Select Into语句

<select into statement> ::=

<select clause><into clause>[ <from clause>[ <where clause> ][ <group by clause> ][ <having clause> ]

[ <select block tail> ] ]

<into clause> ::=

INTO <local variable> [ , <local variable> ]...

Set语句

为了避免不必要的重复定义,这里给出SET语句的两个定义。第一个定义为用户变量赋值;第二个定义为存储过程和存储函数的局部变量赋值。

<set statement> ::=

SET <user variable definition>

[ , <user variable definition> ]...<set statement> ::=

SET <local variable definition>

[ , <local variable definition> ]...<user variable definition> ::=

<user variable> { = | := } <scalar expression><local variable definition> ::=

<local variable> { = | := } <scalar expression>

Set Password语句

<set password statement> ::=

SET PASSWORD [ FOR <user name> ]

= PASSWORD( <password> )

Set Transaction语句

<set transaction statement> ::=

SET [ GLOBAL | SESSION ] TRANSACTION

ISOLATION LEVEL <isolation level>

MySQL开发者SQL权威指南的附录文档

616附录

<isolation level> ::=

READ UNCOMMITTED |READ COMMITTED |REPEATABLE READ |SERIALIZABLE

Show Character Set语句

<show character set statement> ::=

SHOW CHARACTER SET [ LIKE <alphanumeric literal> ]

Show Collation语句

<show collation statement> ::=

SHOW COLLATION [ LIKE <alphanumeric literal> ]

Show Column Types语句

<show column types statement> ::=

SHOW COLUMN TYPES

Show Columns语句

<show columns statement> ::=

SHOW [ FULL ] COLUMNS { FROM | IN } <table specification>[ { FROM | IN } <database name> ][ LIKE <alphanumeric literal> ]

Show Create Database语句

<show create database statement> ::=

SHOW CREATE DATABASE [ IF NOT EXISTS ] <database name>

Show Create Event语句

<show create event statement> ::=

SHOW CREATE EVENT [ <database name> . ] <event name>

Show Create Function语句

<show create function statement> ::=

SHOW CREATE FUNCTION

[ <database name> . ] <stored function name>

Show Create Procedure语句

<show create procedure statement> ::=

SHOW CREATE PROCEDURE

[ <database name> . ] <stored procedure name>

Show Create Table语句

<show create table statement> ::=

SHOW CREATE TABLE <table specification>

Show Create View语句

<show create view statement> ::=

MySQL开发者SQL权威指南的附录文档

SHOW CREATE VIEW <table specification>

Show Databases语句

<show databases statement> ::=

SHOW DATABASES [ LIKE <alphanumeric literal> ]

Show Engine语句

<show engine statement> ::=

SHOW ENGINE <engine namer> { LOGS | STATUS }

Show Engines语句

<show engines statement> ::=

SHOW [ STORAGE ] ENGINES

Show Errors语句

<show errors statement> ::=

SHOW ERRORS

[ LIMIT [ <fetch offset> , ] <fetch number of rows> ] |SHOW [ COUNT(*) ] ERRORS

Show Events语句

<show events statement> ::=

SHOW EVENTS [ FROM <database name> ]

[ LIKE <alphanumeric literal> ]

Show Function语句

<show function status statement> ::=

SHOW FUNCTION STATUS [ LIKE <alphanumeric literal> ]

Show Grants 语句

<show grants statement> ::=

SHOW ACCOUNTS [ FOR <user name> ]

Show Index语句

<show index statement> ::=

SHOW { INDEX | KEY } { FROM | IN }

<table specification> [ { FROM | IN }<database name> ]

Show Privileges语句

<show privileges statement> ::=

SHOW PRIVILEGES

Show Procedure Status语句

<show procedure status statement> ::=

SHOW PROCEDURE STATUS [ LIKE <alphanumeric literal> ]

Show Table Types语句

<show table types statement> ::=

SHOW TABLE TYPES

本文来源:https://www.bwwdw.com/article/3gf4.html

Top