2017-05-08 2 views
1

私はMySQL 5.0.95を使用しています。
"position"というテーブルを作成したいと思います。

以下は、私のクエリは、次のとおりです。MySQL - エラーを示すポジションテーブルを作成

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 'position(
position_ID int(3) not null auto_increment, 
position_name varchar(30) ' at line 1 

私が間違っているのは何:

create table position(
position_ID int(3) not null auto_increment, 
position_name varchar(30) not null, 
primary key(position_ID) 
)ENGINE=INNODB; 

は、しかし、私は以下のエラーを取得しますか?
誰かが私を助けることができますか?

答えて

2

POSITIONは、MySQLの関数です。これがファンクションコールではなく識別子であるかどうかをMySQLに知らせるためには、位置と(カッコの間にスペースを入れる必要があります。 https://dev.mysql.com/doc/refman/5.7/en/keywords.html

Names of built-in functions are permitted as identifiers but may require care to be used as such. For example, COUNT is acceptable as a column name. However, by default, no whitespace is permitted in function invocations between the function name and the following (character. This requirement enables the parser to distinguish whether the name is used in a function call or in nonfunction context.

create table position (
position_ID int(3) not null auto_increment, 
position_name varchar(30) not null, 
primary key(position_ID) 
)ENGINE=INNODB; 

から

あなたが安全であることをいくつかの他の識別子を使用することができます。

create table t_position(
position_ID int(3) not null auto_increment, 
position_name varchar(30) not null, 
primary key(position_ID) 
)ENGINE=INNODB; 

やバッククォートを使用して、それをエスケープ:

create table `position` (
position_ID int(3) not null auto_increment, 
position_name varchar(30) not null, 
primary key(position_ID) 
)ENGINE=INNODB; 
関連する問題