前提・実現したいこと
user_tテーブルとbuy_tテーブルを作ります。
user_tではuserIDを主キーを、buy_tのuserIDを外部キーとして設定します。
buy_tテーブルの作成するためコードを入力後エラーがでました。
文法が違うのか、根本的にキーの使い方が間違っているのかわかりません。
訂正箇所をわかりやすく教えてくれると助かります。
発生している問題・エラーメッセージ
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''購入ID', userID int comment 'ユーザーID',index(userID),itemCode varchar(2' at line 1
該当のソースコード
MariaDB [kagoyume_db]> create table user_t(userID int Primary Key auto_increment comment 'ユーザーID',name varchar(255) comment 'ユーザー名',password varchar(255) comment 'パスワード', mail varchar(255) comment 'メールアドレス', address text comment '住所', total int comment '総購入金額', newDate Datetime comment '登録日時', deleteFlg int default 0 comment '削除フラグ',index(userID) )engine=InnoDB; Query OK, 0 rows affected (0.19 sec) MariaDB [kagoyume_db]> create table buy_t(buyID int Primary Key auto_increment commnet '購入ID', userID int comment 'ユーザーID',itemCode varchar(255) comment'商品コード', type int comment '発送方法',buyDate Datetime comment '購入日時',index(userID), foreign key(userID) references user_t(userID))engine=InnoDB;
試したこと
userIDをindexしてInnoDBしたがエラー。
補足情報(FW/ツールのバージョンなど)
MYSQLのバージョンが分かりません。
回答1件
あなたの回答
tips
プレビュー