您好,欢迎访问一九零五行业门户网

如何使用MySQL保留字作为标识符?

我们必须使用引号来将保留字用作标识符。引号可以是单引号或双引号,取决于ansi_quotes sql模式。
如果禁用了此模式,则标识符引号字符为反引号(“`”)。请考虑以下示例,我们创建了一个名为‘select’的表 −
mysql> create table `select`(id int);query ok, 0 rows affected (0.19 sec)
如果启用了此模式,则可以同时使用反引号(“`”)和双引号(“”)作为标识符引用字符。考虑以下示例,我们创建了一个名为‘trigger’的表 −
mysql> create table "trigger" (id int);error 1064 (42000): you have an error in your sql syntax; check the manual thatcorresponds to your mysql server version for the right syntax to use near '"trigger" (id int)' at line 1mysql> set sql_mode = 'ansi_quotes';query ok, 0 rows affected (0.03 sec)mysql> create table "trigger" (id int);query ok, 0 rows affected (0.17 sec)mysql> create table `describe`(id int);query ok, 0 rows affected (0.11 sec)
上面的查询显示,我们可以在启用“ansi_quotes”模式后,同时使用反引号(“`”)和双引号(“”)作为标识符引用字符。
以上就是如何使用mysql保留字作为标识符?的详细内容。
其它类似信息

推荐信息