六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

詳細說明MySQL5.7中的關鍵字與保留字

[摘要]最近在將數據從Oracle遷移到MySQL的過程中,遇到一些問題,其中就包括關鍵字。下面這篇文章主要給大家介紹了MySQL 5.7中的關鍵字與保留字的相關資料,文中介紹的非常詳細,需要的朋友可以參考學習,下面來一起看看吧。前言MySQL和Oracle的關鍵字還是不盡相同的,在Oracle數據庫中,...
最近在將數據從Oracle遷移到MySQL的過程中,遇到一些問題,其中就包括關鍵字。下面這篇文章主要給大家介紹了MySQL 5.7中的關鍵字與保留字的相關資料,文中介紹的非常詳細,需要的朋友可以參考學習,下面來一起看看吧。

前言

MySQL和Oracle的關鍵字還是不盡相同的,在Oracle數據庫中,我們的數據表中定義了大量的code字段用來表示主鍵,但是在MySQL中code是關鍵字,使用以前的處理方法就有些“水土不服”。

下面我們來了解一下MySQL中的關鍵字和保留字。

什么是關鍵字和保留字

關鍵字是指在SQL中有意義的字。 某些關鍵字(例如SELECT,DELETE或BIGINT)是保留的,需要特殊處理才能用作表和列名稱等標識符。 這一點對于內置函數的名稱也適用。

如何使用關鍵字和保留字

非保留關鍵字允許作為標識符,不需要加引號。 如果您要適用保留字作為標識符,就必須適用引號。

舉個例子,BEGIN和END是關鍵字,但不是保留字,因此它們用作標識符不需要引號。 INTERVAL是保留關鍵字,必須加上引號才能用作標識符。

mysql>
mysql> use hoegh;
Database changed
mysql>
mysql> CREATE TABLE interval (begin INT, end INT);
ERROR 1064 (42000):
mysql>
mysql> CREATE TABLE `interval` (begin INT, end INT);
Query OK, 0 rows affected (0.42 sec)

mysql>
mysql> show create table `interval`;
+----------+---------------------------------------------------------
  Table   Create Table
+----------+---------------------------------------------------------
  interval   CREATE TABLE `interval` (
 `begin` int(11) DEFAULT NULL,
 `end` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1  
+----------+---------------------------------------------------------
1 row in set (0.00 sec)

mysql>

我們看到,第一條語句中表名使用了保留字interval,執行失敗;

第二條語句對interval加了引號,執行成功。

在這里需要注意的是,引號必須是反引號,而非單引號。否則會報錯,如下所示:

mysql>
mysql> drop table `interval`;--使用反引號
Query OK, 0 rows affected (0.11 sec)

mysql>
mysql> create table 'interval' (begin INT, end INT);--使用單引號,報錯
ERROR 1064 (42000):

mysql>

有一個例外

如果標識符在限定名稱(數據庫名)的句點之后,即使是保留關鍵字也不需要引號。

我們以hoegh數據庫為例,如果表名寫為hoegh.interval就不需要對保留字interval加引號了。

mysql>
mysql> create table hoegh.interval (begin INT, end INT);
Query OK, 0 rows affected (0.19 sec)

mysql>
mysql> show create table hoegh.interval;
+----------+---------------------------------------------------------
  Table   Create Table
+----------+---------------------------------------------------------
  interval   CREATE TABLE `interval` (
 `begin` int(11) DEFAULT NULL,
 `end` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1  
+----------+---------------------------------------------------------
1 row in set (0.00 sec)

mysql>

關于使用內置函數名稱

允許內置函數的名稱可以作為標識符,但最好謹慎使用。例如,COUNT作為列名稱是合法的。但是,默認情況下,在函數名和后面的(之間的函數調用中不允許有空格。這個限制使解析器能夠區分名稱是用于函數調用還是用在非函數上下文中。

附錄

在某些時候,您可能需要升級到更高版本,因此最好查看一下未來的保留字。您可以在涵蓋更高版本的MySQL的手冊中找到這些。對于表中的大多數保留字,在標準SQL中禁止作為列或表的名稱(例如,GROUP)。其中一些保留字,是由于MySQL需要它們并使用一個yacc解析器。

以下列出三張表格:

第一個表格10.2顯示MySQL 5.7中的關鍵字和保留字。保留的關鍵字標記為(R)。此外,_FILENAME是保留的。

第二個表格10.3顯示MySQL 5.7相比5.6版本新增的保留字。

第三個表格10.4顯示MySQL 5.7相比5.6版本刪除的保留字。

Table 10.2 Keywords and Reserved Words in MySQL 5.7

ACCESSIBLE (R)ACCOUNT[a]ACTION














































ADD (R)AFTERAGAINST














































AGGREGATEALGORITHMALL (R)














































ALTER (R)ALWAYS[b]ANALYSE














































ANALYZE (R)AND (R)ANY














































AS (R)ASC (R)ASCII














































ASENSITIVE (R)ATAUTOEXTEND_SIZE














































AUTO_INCREMENTAVGAVG_ROW_LENGTH














































BACKUPBEFORE (R)BEGIN














































BETWEEN (R)BIGINT (R)BINARY (R)














































BINLOGBITBLOB (R)














































BLOCKBOOLBOOLEAN














































BOTH (R)BTREEBY (R)














































BYTECACHECALL (R)














































CASCADE (R)CASCADEDCASE (R)














































CATALOG_NAMECHAINCHANGE (R)














































CHANGEDCHANNEL[c]CHAR (R)














































CHARACTER (R)CHARSETCHECK (R)














































CHECKSUMCIPHERCLASS_ORIGIN














































CLIENTCLOSECOALESCE














































CODECOLLATE (R)COLLATION














































COLUMN (R)COLUMNSCOLUMN_FORMAT














































COLUMN_NAMECOMMENTCOMMIT














































COMMITTEDCOMPACTCOMPLETION














































COMPRESSEDCOMPRESSION[d]CONCURRENT














































CONDITION (R)CONNECTIONCONSISTENT














































CONSTRAINT (R)CONSTRAINT_CATALOGCONSTRAINT_NAME














































CONSTRAINT_SCHEMACONTAINSCONTEXT














































CONTINUE (R)CONVERT (R)CPU














































CREATE (R)CROSS (R)CUBE














































CURRENTCURRENT_DATE (R)CURRENT_TIME (R)














































CURRENT_TIMESTAMP (R)CURRENT_USER (R)CURSOR (R)














































CURSOR_NAMEDATADATABASE (R)














































DATABASES (R)DATAFILEDATE














































DATETIMEDAYDAY_HOUR (R)














































DAY_MICROSECOND (R)DAY_MINUTE (R)DAY_SECOND (R)














































DEALLOCATEDEC (R)DECIMAL (R)














































DECLARE (R)DEFAULT (R)DEFAULT_AUTH














































DEFINERDELAYED (R)DELAY_KEY_WRITE














































DELETE (R)DESC (R)DESCRIBE (R)














































DES_KEY_FILEDETERMINISTIC (R)DIAGNOSTICS














































DIRECTORYDISABLEDISCARD














































DISKDISTINCT (R)DISTINCTROW (R)














































p (R)DODOUBLE (R)














































DROP (R)DUAL (R)DUMPFILE














































DUPLICATEDYNAMICEACH (R)














































ELSE (R)ELSEIF (R)ENABLE














































ENCLOSED (R)ENCRYPTION[e]END














































ENDSENGINEENGINES














































ENUMERRORERRORS














































ESCAPEESCAPED (R)EVENT














































EVENTSEVERYEXCHANGE














































EXECUTEEXISTS (R)EXIT (R)














































EXPANSIONEXPIREEXPLAIN (R)














































EXPORTEXTENDEDEXTENT_SIZE














































FALSE (R)FASTFAULTS














































FETCH (R)FIELDSFILE














































FILE_BLOCK_SIZE[f]FILTER[g]FIRST














































FIXEDFLOAT (R)FLOAT4 (R)














































FLOAT8 (R)FLUSHFOLLOWS[h]














































FOR (R)FORCE (R)FOREIGN (R)














































FORMATFOUNDFROM (R)














































FULLFULLTEXT (R)FUNCTION














































GENERALGENERATED[i] (R)GEOMETRY














































GEOMETRYCOLLECTIONGET (R)GET_FORMAT














































GLOBALGRANT (R)GRANTS














































GROUP (R)GROUP_REPLICATION[j]HANDLER














































HASHHAVING (R)HELP














































HIGH_PRIORITY (R)HOSTHOSTS














































HOURHOUR_MICROSECOND (R)HOUR_MINUTE (R)














































HOUR_SECOND (R)IDENTIFIEDIF (R)














































IGNORE (R)IGNORE_SERVER_IDSIMPORT














































IN (R)INDEX (R)INDEXES














































INFILE (R)INITIAL_SIZEINNER (R)














































INOUT (R)INSENSITIVE (R)INSERT (R)














































INSERT_METHODINSTALLINSTANCE[k]














































INT (R)INT1 (R)INT2 (R)














































INT3 (R)INT4 (R)INT8 (R)














































INTEGER (R)INTERVAL (R)INTO (R)














































INVOKERIOIO_AFTER_GTIDS (R)














































IO_BEFORE_GTIDS (R)IO_THREADIPC














































IS (R)ISOLATIONISSUER














































ITERATE (R)JOIN (R)JSON[l]














































KEY (R)KEYS (R)KEY_BLOCK_SIZE














































KILL (R)LANGUAGELAST














































LEADING (R)LEAVE (R)LEAVES














































LEFT (R)LESSLEVEL














































LIKE (R)LIMIT (R)LINEAR (R)














































LINES (R)LINESTRINGLIST














































LOAD (R)LOCALLOCALTIME (R)














































LOCALTIMESTAMP (R)LOCK (R)LOCKS














































LOGFILELOGSLONG (R)














































LONGBLOB (R)LONGTEXT (R)LOOP (R)














































LOW_PRIORITY (R)MASTERMASTER_AUTO_POSITION














































MASTER_BIND (R)MASTER_CONNECT_RETRYMASTER_DELAY














































MASTER_HEARTBEAT_PERIODMASTER_HOSTMASTER_LOG_FILE














































MASTER_LOG_POSMASTER_PASSWORDMASTER_PORT














































MASTER_RETRY_COUNTMASTER_SERVER_IDMASTER_SSL














































MASTER_SSL_CAMASTER_SSL_CAPATHMASTER_SSL_CERT














































MASTER_SSL_CIPHERMASTER_SSL_CRLMASTER_SSL_CRLPATH














































MASTER_SSL_KEYMASTER_SSL_VERIFY_SERVER_CERT(R)MASTER_TLS_VERSION[m]














































MASTER_USERMATCH (R)MAXVALUE (R)














































MAX_CONNECTIONS_PER_HOURMAX_QUERIES_PER_HOURMAX_ROWS














































MAX_SIZEMAX_STATEMENT_TIME[n]MAX_UPDATES_PER_HOUR














































MAX_USER_CONNECTIONSMEDIUMMEDIUMBLOB (R)














































MEDIUMINT (R)MEDIUMTEXT (R)MEMORY














































MERGEMESSAGE_TEXTMICROSECOND














































MIDDLEINT (R)MIGRATEMINUTE














































MINUTE_MICROSECOND (R)MINUTE_SECOND (R)MIN_ROWS














































MOD (R)MODEMODIFIES (R)














































MODIFYMONTHMULTILINESTRING














































MULTIPOINTMULTIPOLYGONMUTEX














































MYSQL_ERRNONAMENAMES














































NATIONALNATURAL (R)NCHAR














































NDBNDBCLUSTERNEVER[o]














































NEWNEXTNO














































NODEGROUPNONBLOCKING[p]NONE














































NOT (R)NO_WAITNO_WRITE_TO_BINLOG (R)














































NULL (R)NUMBERNUMERIC (R)














































NVARCHAROFFSETOLD_PASSWORD[q]














































ON (R)ONEONLY














































OPENOPTIMIZE (R)OPTIMIZER_COSTS[r] (R)














































OPTION (R)OPTIONALLY (R)OPTIONS














































OR (R)ORDER (R)OUT (R)














































OUTER (R)OUTFILE (R)OWNER














































PACK_KEYSPAGEPARSER














































PARSE_GCOL_EXPR[s]PARTIALPARTITION (R)














































PARTITIONINGPARTITIONSPASSWORD














































PHASEPLUGINPLUGINS














































PLUGIN_DIRPOINTPOLYGON














































PORTPRECEDES[t]PRECISION (R)














































PREPAREPRESERVEPREV














































PRIMARY (R)PRIVILEGESPROCEDURE (R)














































PROCESSLISTPROFILEPROFILES














































PROXYPURGE (R)QUARTER














































QUERYQUICKRANGE (R)














































READ (R)READS (R)READ_ONLY














































READ_WRITE (R)REAL (R)REBUILD














































RECOVERREDOFILEREDO_BUFFER_SIZE














































REDUNDANTREFERENCES (R)REGEXP (R)














































RELAYRELAYLOGRELAY_LOG_FILE














































RELAY_LOG_POSRELAY_THREADRELEASE (R)














































RELOADREMOVERENAME (R)














































REORGANIZEREPAIRREPEAT (R)














































REPEATABLEREPLACE (R)REPLICATE_DO_DB[u]














































REPLICATE_DO_TABLE[v]REPLICATE_IGNORE_DB[w]REPLICATE_IGNORE_TABLE[x]














































REPLICATE_REWRITE_DB[y]REPLICATE_WILD_DO_TABLE[z]REPLICATE_WILD_IGNORE_TABLE[aa]














































REPLICATIONREQUIRE (R)RESET














































RESIGNAL (R)RESTORERESTRICT (R)














































RESUMERETURN (R)RETURNED_SQLSTATE














































RETURNSREVERSEREVOKE (R)














































RIGHT (R)RLIKE (R)ROLLBACK














































ROLLUPROTATE[ab]ROUTINE














































ROWROWSROW_COUNT














































ROW_FORMATRTREESAVEPOINT














































SCHEDULESCHEMA (R)SCHEMAS (R)














































SCHEMA_NAMESECONDSECOND_MICROSECOND (R)














































SECURITYSELECT (R)SENSITIVE (R)














































SEPARATOR (R)SERIALSERIALIZABLE














































SERVERSESSIONSET (R)














































SHARESHOW (R)SHUTDOWN














































SIGNAL (R)SIGNEDSIMPLE














































SLAVESLOWSMALLINT (R)














































SNAPSHOTSOCKETSOME














































SONAMESOUNDSSOURCE














































SPATIAL (R)SPECIFIC (R)SQL (R)














































SQLEXCEPTION (R)SQLSTATE (R)SQLWARNING (R)














































SQL_AFTER_GTIDSSQL_AFTER_MTS_GAPSSQL_BEFORE_GTIDS














































SQL_BIG_RESULT (R)SQL_BUFFER_RESULTSQL_CACHE














































SQL_CALC_FOUND_ROWS (R)SQL_NO_CACHESQL_SMALL_RESULT (R)














































SQL_THREADSQL_TSI_DAYSQL_TSI_HOUR














































SQL_TSI_MINUTESQL_TSI_MONTHSQL_TSI_QUARTER














































SQL_TSI_SECONDSQL_TSI_WEEKSQL_TSI_YEAR














































SSL (R)STACKEDSTART














































STARTING (R)STARTSSTATS_AUTO_RECALC














































STATS_PERSISTENTSTATS_SAMPLE_PAGESSTATUS














































STOPSTORAGESTORED[ac] (R)














































STRAIGHT_JOIN (R)STRINGSUBCLASS_ORIGIN














































SUBJECTSUBPARTITIONSUBPARTITIONS














































SUPERSUSPENDSWAPS














































SWITCHESTABLE (R)TABLES














































TABLESPACETABLE_CHECKSUMTABLE_NAME














































TEMPORARYTEMPTABLETERMINATED (R)














































TEXTTHANTHEN (R)














































TIMETIMESTAMPTIMESTAMPADD














































TIMESTAMPDIFFTINYBLOB (R)TINYINT (R)














































TINYTEXT (R)TO (R)TRAILING (R)














































TRANSACTIONTRIGGER (R)TRIGGERS














































TRUE (R)TRUNCATETYPE














































TYPESUNCOMMITTEDUNDEFINED














































UNDO (R)UNDOFILEUNDO_BUFFER_SIZE














































UNICODEUNINSTALLUNION (R)














































UNIQUE (R)UNKNOWNUNLOCK (R)














































UNSIGNED (R)UNTILUPDATE (R)














































UPGRADEUSAGE (R)USE (R)














































USERUSER_RESOURCESUSE_FRM














































USING (R)UTC_DATE (R)UTC_TIME (R)














































UTC_TIMESTAMP (R)VALIDATION[ad]VALUE














































VALUES (R)VARBINARY (R)VARCHAR (R)














































VARCHARACTER (R)VARIABLESVARYING (R)














































VIEWVIRTUAL[ae] (R)WAIT














































WARNINGSWEEKWEIGHT_STRING














































WHEN (R)WHERE (R)WHILE (R)














































WITH (R)WITHOUT[af]WORK














































WRAPPERWRITE (R)X509














































XAXID[ag]XML














































XOR (R)YEARYEAR_MONTH (R)














































ZEROFILL (R)














































[a] ACCOUNT: added in 5.7.6 (nonreserved)

[b] ALWAYS: added in 5.7.6 (nonreserved)

[c] CHANNEL: added in 5.7.6 (nonreserved)

[d] COMPRESSION: added in 5.7.8 (nonreserved)

[e] ENCRYPTION: added in 5.7.11 (nonreserved)

[f] FILE_BLOCK_SIZE: added in 5.7.6 (nonreserved)

[g] FILTER: added in 5.7.3 (nonreserved)

[h] FOLLOWS: added in 5.7.2 (nonreserved)

[i] GENERATED: added in 5.7.6 (reserved)

[j] GROUP_REPLICATION: added in 5.7.6 (nonreserved)

[k] INSTANCE: added in 5.7.11 (nonreserved)

[l] JSON: added in 5.7.8 (nonreserved)

[m] MASTER_TLS_VERSION: added in 5.7.10 (nonreserved)

[n] MAX_STATEMENT_TIME: added in 5.7.4 (nonreserved); removed in 5.7.8

[o] NEVER: added in 5.7.4 (nonreserved)

[p] NONBLOCKING: removed in 5.7.6

[q] OLD_PASSWORD: removed in 5.7.5

[r] OPTIMIZER_COSTS: added in 5.7.5 (reserved)

[s] PARSE_GCOL_EXPR: added in 5.7.6 (reserved); became nonreserved in 5.7.8

[t] PRECEDES: added in 5.7.2 (nonreserved)

[u] REPLICATE_DO_DB: added in 5.7.3 (nonreserved)

[v] REPLICATE_DO_TABLE: added in 5.7.3 (nonreserved)

[w] REPLICATE_IGNORE_DB: added in 5.7.3 (nonreserved)

[x] REPLICATE_IGNORE_TABLE: added in 5.7.3 (nonreserved)

[y] REPLICATE_REWRITE_DB: added in 5.7.3 (nonreserved)

[z] REPLICATE_WILD_DO_TABLE: added in 5.7.3 (nonreserved)

[aa] REPLICATE_WILD_IGNORE_TABLE: added in 5.7.3 (nonreserved)

[ab] ROTATE: added in 5.7.11 (nonreserved)

[ac] STORED: added in 5.7.6 (reserved)

[ad] VALIDATION: added in 5.7.5 (nonreserved)

[ae] VIRTUAL: added in 5.7.6 (reserved)

[af] WITHOUT: added in 5.7.5 (nonreserved)

[ag] XID: added in 5.7.5 (nonreserved)

Table 10.3 Keywords and Reserved Words Added in MySQL 5.7 Compared to MySQL 5.6

ACCOUNTALWAYSCHANNEL
COMPRESSIONENCRYPTIONFILE_BLOCK_SIZE
FILTERFOLLOWSGENERATED (R)
GROUP_REPLICATIONINSTANCEJSON
MASTER_TLS_VERSIONNEVEROPTIMIZER_COSTS (R)
PARSE_GCOL_EXPRPRECEDESREPLICATE_DO_DB
REPLICATE_DO_TABLEREPLICATE_IGNORE_DBREPLICATE_IGNORE_TABLE
REPLICATE_REWRITE_DBREPLICATE_WILD_DO_TABLEREPLICATE_WILD_IGNORE_TABLE
ROTATESTACKEDSTORED (R)
VALIDATIONVIRTUAL (R)WITHOUT
XID

Table 10.4 Keywords and Reserved Words Removed in MySQL 5.7 Compared to MySQL 5.6

OLD_PASSWORD

總結

以上就是詳解MySQL5.7中的關鍵字與保留字的詳細內容,更多請關注php中文網其它相關文章!


學習教程快速掌握從入門到精通的SQL知識。




主站蜘蛛池模板: 天堂网址| 羞羞一区二区三区四区片 | 日韩中文字幕高清在线专区 | 色婷五月 | 日韩欧美福利 | 青娱极品盛宴国产一区 | 日本一区二区三区在线 视频观看免费 | 天天看天天碰 | 亚洲 欧美 清纯 丝袜 另类 | 色婷婷九月 | 欧美一级美片在线观看免费 | 视频在线观看免费网址 | 日本黄网站高清色大全 | 日本在线成人 | 欧美一级做a爰片免费 | 伊人久久精品 | 欧美一区日韩一区中文字幕页 | 亚洲男人的天堂久久香蕉网 | 日本午夜在线视频 | 综合婷婷丁香 | 日韩在线视频导航 | 欧洲毛片真人 | 手机在线观看伦理片 | 亚洲午夜精品久久久久久抢 | 亚洲大片在线观看 | 欧美午夜精品 | 日本在线视频免费看 | 欧美一二三 | 色网站免费看 | 一二三四视频免费观看影视 | 人妖欧美一区二区三区四区 | 四虎影视网 | 欧美一级性 | 色先锋资源网 | 日本最新中文字幕 | 中文字幕亚洲日本岛国片 | 欧美亚洲综合另类 | 日本xxxx在线观看 | 天天干天天操天天插 | 日韩精品视频免费观看 | 天天躁夜夜躁狠狠躁躁 |