创建表时
mysql> CREATE TABLE department(d_id INT(10) PRIMARY KEY,
-> d_name VARCHAR(20) NOT NULL,
-> function VARCHAR(20),
-> address VARCHAR(30));
报错
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax
to use near 'function VARCHAR(20),
addre ss VARCHAR(30))' at line 3
原因:误用了保留字function
需要用时,需要在保留字两边加上反引号``(英文输入法tab键上方),不能用单引号
A
ACCESSIBLE ®
ACTION
ADD ®
AFTER
AGAINST
AGGREGATE
ALGORITHM
ALL ®
ALTER ®
ANALYZE ®
AND ®
ANY
AS ®
ASC ®
ASCII
ASENSITIVE ®
AT
AUTHORS
AUTOEXTEND_SIZE
AUTO_INCREMENT
AVG
AVG_ROW_LENGTH
B
BACKUP
BEFORE ®
BEGIN
BETWEEN ®
BIGINT ®
BINARY ®
BINLOG
BIT
BLOB ®
BLOCK
BOOL
BOOLEAN
BOTH ®
BTREE
BY ®
BYTE
C
CACHE
CALL ®
CASCADE ®
CASCADED
CASE ®
CATALOG_NAME
CHAIN
CHANGE ®
CHANGED
CHAR ®
CHARACTER ®
CHARSET
CHECK ®
CHECKSUM
CIPHER
CLASS_ORIGIN
CLIENT
CLOSE
COALESCE
CODE
COLLATE ®
COLLATION
COLUMN ®
COLUMNS
COLUMN_NAME
COMMENT
COMMIT
COMMITTED
COMPACT
COMPLETION
COMPRESSED
CONCURRENT
CONDITION ®
CONNECTION
CONSISTENT
CONSTRAINT ®
CONSTRAINT_CATALOG
CONSTRAINT_NAME
CONSTRAINT_SCHEMA
CONTAINS
CONTEXT
CONTINUE ®
CONTRIBUTORS
CONVERT ®
CPU
CREATE ®
CROSS ®
CUBE
CURRENT_DATE ®
CURRENT_TIME ®
CURRENT_TIMESTAMP ®
CURRENT_USER ®
CURSOR ®
CURSOR_NAME
D
DATA
DATABASE ®
DATABASES ®
DATAFILE
DATE
DATETIME
DAY
DAY_HOUR ®
DAY_MICROSECOND ®
DAY_MINUTE ®
DAY_SECOND ®
DEALLOCATE
DEC ®
DECIMAL ®
DECLARE ®
DEFAULT ®
DEFINER
DELAYED ®
DELAY_KEY_WRITE
DELETE ®
DESC ®
DESCRIBE ®
DES_KEY_FILE
DETERMINISTIC ®
DIRECTORY
DISABLE
DISCARD
DISK
DISTINCT ®
DISTINCTROW ®
DIV ®
DO
DOUBLE ®
DROP ®
DUAL ®
DUMPFILE
DUPLICATE
DYNAMIC
E
EACH ®
ELSE ®
ELSEIF ®
ENABLE
ENCLOSED ®
END
ENDS
ENGINE
ENGINES
ENUM
ERROR; added in 5.5.3 (nonreserved)
ERRORS
ESCAPE
ESCAPED ®
EVENT
EVENTS
EVERY
EXECUTE
EXISTS ®
EXIT ®
EXPANSION
EXPLAIN ®
EXTENDED
EXTENT_SIZE
F
FALSE ®
FAST
FAULTS
FETCH ®
FIELDS
FILE
FIRST
FIXED
FLOAT ®
FLOAT4 ®
FLOAT8 ®
FLUSH
FOR ®
FORCE ®
FOREIGN ®
FOUND
FRAC_SECOND; removed in 5.5.3
FROM ®
FULL
FULLTEXT ®
FUNCTION
G
GENERAL; added in 5.5.3 (reserved); became nonreserved in 5.5.8
GEOMETRY
GEOMETRYCOLLECTION
GET_FORMAT
GLOBAL
GRANT ®
GRANTS
GROUP ®
H
HANDLER
HASH
HAVING ®
HELP
HIGH_PRIORITY ®
HOST
HOSTS
HOUR
HOUR_MICROSECOND ®
HOUR_MINUTE ®
HOUR_SECOND ®
I
IDENTIFIED
IF ®
IGNORE ®
IGNORE_SERVER_IDS; became nonreserved in 5.5.8
IMPORT
IN ®
INDEX ®
INDEXES
INFILE ®
INITIAL_SIZE
INNER ®
INNOBASE; removed in 5.5.3
INNODB; removed in 5.5.3
INOUT ®
INSENSITIVE ®
INSERT ®
INSERT_METHOD
INSTALL
INT ®
INT1 ®
INT2 ®
INT3 ®
INT4 ®
INT8 ®
INTEGER ®
INTERVAL ®
INTO ®
INVOKER
IO
IO_THREAD
IPC
IS ®
ISOLATION
ISSUER
ITERATE ®
J
JOIN ®
K
KEY ®
KEYS ®
KEY_BLOCK_SIZE
KILL ®
L
LANGUAGE
LAST
LEADING ®
LEAVE ®
LEAVES
LEFT ®
LESS
LEVEL
LIKE ®
LIMIT ®
LINEAR ®
LINES ®
LINESTRING
LIST
LOAD ®
LOCAL
LOCALTIME ®
LOCALTIMESTAMP ®
LOCK ®
LOCKS
LOGFILE
LOGS
LONG ®
LONGBLOB ®
LONGTEXT ®
LOOP ®
LOW_PRIORITY ®
M
MASTER
MASTER_CONNECT_RETRY
MASTER_HEARTBEAT_PERIOD; became nonreserved in 5.5.8
MASTER_HOST
MASTER_LOG_FILE
MASTER_LOG_POS
MASTER_PASSWORD
MASTER_PORT
MASTER_SERVER_ID
MASTER_SSL
MASTER_SSL_CA
MASTER_SSL_CAPATH
MASTER_SSL_CERT
MASTER_SSL_CIPHER
MASTER_SSL_KEY
MASTER_SSL_VERIFY_SERVER_CERT ®
MASTER_USER
MATCH ®
MAXVALUE ®
MAX_CONNECTIONS_PER_HOUR
MAX_QUERIES_PER_HOUR
MAX_ROWS
MAX_SIZE
MAX_UPDATES_PER_HOUR
MAX_USER_CONNECTIONS
MEDIUM
MEDIUMBLOB ®
MEDIUMINT ®
MEDIUMTEXT ®
MEMORY
MERGE
MESSAGE_TEXT
MICROSECOND
MIDDLEINT ®
MIGRATE
MINUTE
MINUTE_MICROSECOND ®
MINUTE_SECOND ®
MIN_ROWS
MOD ®
MODE
MODIFIES ®
MODIFY
MONTH
MULTILINESTRING
MULTIPOINT
MULTIPOLYGON
MUTEX
MYSQL_ERRNO
N
NAME
NAMES
NATIONAL
NATURAL ®
NCHAR
NDB
NDBCLUSTER
NEW
NEXT
NO
NODEGROUP
NONE
NOT ®
NO_WAIT
NO_WRITE_TO_BINLOG ®
NULL ®
NUMERIC ®
NVARCHAR
O
OFFSET
OLD_PASSWORD
ON ®
ONE
ONE_SHOT
OPEN
OPTIMIZE ®
OPTION ®
OPTIONALLY ®
OPTIONS
OR ®
ORDER ®
OUT ®
OUTER ®
OUTFILE ®
OWNER
P
PACK_KEYS
PAGE
PARSER
PARTIAL
PARTITION
PARTITIONING
PARTITIONS
PASSWORD
PHASE
PLUGIN
PLUGINS
POINT
POLYGON
PORT
PRECISION ®
PREPARE
PRESERVE
PREV
PRIMARY ®
PRIVILEGES
PROCEDURE ®
PROCESSLIST
PROFILE
PROFILES
PROXY; added in 5.5.7 (nonreserved)
PURGE ®
Q
QUARTER
QUERY
QUICK
R
RANGE ®
READ ®
READS ®
READ_ONLY
READ_WRITE ®
REAL ®
REBUILD
RECOVER
REDOFILE
REDO_BUFFER_SIZE
REDUNDANT
REFERENCES ®
REGEXP ®
RELAY; added in 5.5.3 (nonreserved)
RELAYLOG
RELAY_LOG_FILE
RELAY_LOG_POS
RELAY_THREAD
RELEASE ®
RELOAD
REMOVE
RENAME ®
REORGANIZE
REPAIR
REPEAT ®
REPEATABLE
REPLACE ®
REPLICATION
REQUIRE ®
RESET
RESIGNAL ®
RESTORE
RESTRICT ®
RESUME
RETURN ®
RETURNS
REVOKE ®
RIGHT ®
RLIKE ®
ROLLBACK
ROLLUP
ROUTINE
ROW
ROWS
ROW_FORMAT
RTREE
S
SAVEPOINT
SCHEDULE
SCHEMA ®
SCHEMAS ®
SCHEMA_NAME
SECOND
SECOND_MICROSECOND ®
SECURITY
SELECT ®
SENSITIVE ®
SEPARATOR ®
SERIAL
SERIALIZABLE
SERVER
SESSION
SET ®
SHARE
SHOW ®
SHUTDOWN
SIGNAL ®
SIGNED
SIMPLE
SLAVE
SLOW; added in 5.5.3 (reserved); became nonreserved in 5.5.8
SMALLINT ®
SNAPSHOT
SOCKET
SOME
SONAME
SOUNDS
SOURCE
SPATIAL ®
SPECIFIC ®
SQL ®
SQLEXCEPTION ®
SQLSTATE ®
SQLWARNING ®
SQL_BIG_RESULT ®
SQL_BUFFER_RESULT
SQL_CACHE
SQL_CALC_FOUND_ROWS ®
SQL_NO_CACHE
SQL_SMALL_RESULT ®
SQL_THREAD
SQL_TSI_DAY
SQL_TSI_FRAC_SECOND; removed in 5.5.3
SQL_TSI_HOUR
SQL_TSI_MINUTE
SQL_TSI_MONTH
SQL_TSI_QUARTER
SQL_TSI_SECOND
SQL_TSI_WEEK
SQL_TSI_YEAR
SSL ®
START
STARTING ®
STARTS
STATUS
STOP
STORAGE
STRAIGHT_JOIN ®
STRING
SUBCLASS_ORIGIN
SUBJECT
SUBPARTITION
SUBPARTITIONS
SUPER
SUSPEND
SWAPS
SWITCHES
T
TABLE ®
TABLES
TABLESPACE
TABLE_CHECKSUM
TABLE_NAME
TEMPORARY
TEMPTABLE
TERMINATED ®
TEXT
THAN
THEN ®
TIME
TIMESTAMP
TIMESTAMPADD
TIMESTAMPDIFF
TINYBLOB ®
TINYINT ®
TINYTEXT ®
TO ®
TRAILING ®
TRANSACTION
TRIGGER ®
TRIGGERS
TRUE ®
TRUNCATE
TYPE
TYPES
U
UNCOMMITTED
UNDEFINED
UNDO ®
UNDOFILE
UNDO_BUFFER_SIZE
UNICODE
UNINSTALL
UNION ®
UNIQUE ®
UNKNOWN
UNLOCK ®
UNSIGNED ®
UNTIL
UPDATE ®
UPGRADE
USAGE ®
USE ®
USER
USER_RESOURCES
USE_FRM
USING ®
UTC_DATE ®
UTC_TIME ®
UTC_TIMESTAMP ®
V
VALUE
VALUES ®
VARBINARY ®
VARCHAR ®
VARCHARACTER ®
VARIABLES
VARYING ®
VIEW
W
WAIT
WARNINGS
WEEK
WHEN ®
WHERE ®
WHILE ®
WITH ®
WORK
WRAPPER
WRITE ®
X
X509
XA
XML
XOR ®
Y
YEAR
YEAR_MONTH ®
Z
ZEROFILL ®
MySQL 5.5 New Keywords and Reserved Words
The following list shows the keywords and reserved words that are added in MySQL 5.5, compared to MySQL 5.1. Reserved keywords are marked with ®.
C
CATALOG_NAME
CLASS_ORIGIN
COLUMN_NAME
CONSTRAINT_CATALOG
CONSTRAINT_NAME
CONSTRAINT_SCHEMA
CURSOR_NAME
E
ERROR
G
GENERAL
I
IGNORE_SERVER_IDS
M
MASTER_HEARTBEAT_PERIOD
MESSAGE_TEXT
MYSQL_ERRNO
P
PROXY
R
RELAY
RELAYLOG
RESIGNAL ®
S
SCHEMA_NAME
SIGNAL ®
SLOW
SUBCLASS_ORIGIN
T
TABLE_NAME
X
XML
参考网址:https://dev.mysql.com/doc/refman/5.5/en/keywords.html#keywords-5-5-detailed-S