下記を「id int AUTO_INCREMENT NOT NULL primary key,」にすることでエラー解消しませんか?
id int primary key auto_increment,
コマンドプロンプトにて、sqlでテーブルを作成したいのですが、下記の通りエラーが出てしまいます。
原因、対処法がわかる方教えていただきたいです。
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 'current_timestamp
)' at line 9
例)
または、問題・エラーが起きている画像をここにドラッグアンドドロップ
mysql> create table cafe.contacts(
id int primary key auto_increment,
name varchar(50) not null,
kana varchar(50) not null,
tel varchar(11),
email varchar(100) not null,
body text,
create_at datetime current_timestamp
);
例)
ここに問題・エラーに対して試したことを記載してください。
以下のコマンドでも同様のエラーがでました。
create table cafe.contacts(
id int primary key,
name varchar(50) not null,
kana varchar(50) not null,
tel varchar(11),
email varchar(100) not null,
body text,
create_at datetime,
auto_increment(id),
current_timestamp(created_at)
);
また、以下のコマンドではテーブルが作成できました。
create table cafe.user (id int, name varchar(10));
Query OK, 0 rows affected (0.14 sec)
下記を「id int AUTO_INCREMENT NOT NULL primary key,」にすることでエラー解消しませんか?
id int primary key auto_increment,
@juza11
Questionerありがとうございます。
アドバイスの通りやってみたのですが、同様のエラーが出てしまいました。
「create_at datetime current_timestamp」
の部分を
「create_at datetime current_timestamp」
にすると、テーブルは作成は作成できました。
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 'current_timestamp
)' at line 9
defaultがないからでは?
- create_at datetime current_timestamp
+ create_at datetime default current_timestamp
@juza11
Questionerその通りでした。
ありがとうございます。