MySQL 5.5 を使用すると、クエリCREATE TABLE
とINSERT
クエリを個別に実行できますが、それらをスクリプトに入れると.sql
、次のエラーが 2 回発生します。
エラー 1064 (42000): SQL 構文にエラーがあります。
ここで推奨されているように GO ステートメントを使用しようとしましたが ( SQL スクリプトは機能しませんが、個々のクエリは機能します)、うまくいきませんでした。
コメントのおかげで、現在動作しているスクリプトは次のとおりです。
-- Create the table
CREATE TABLE person (
id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
age INTEGER
);
-- Populate the table
INSERT INTO person
(id, first_name, last_name, age)
VALUES
(0, 'Zed', 'Shaw', 37),
(1, 'Terry', 'Berry', 42),
(2, 'Tyler', 'Brown', 25),
(3, 'Frank', 'Smith', 100);
ご協力いただきありがとうございます!
完全なエラー メッセージは次のとおりです。
mysql> SOURCE ~/code/Learn-SQL-The-Hard-Way/Exercise-12-Destroying-And-Altering-Tables/recreate-person-table.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 '--Create the table
CREATE TABLE person (
id INTEGER PRIMARY KEY,
first_n' at line 1
ERROR:
No query specified
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 '--Populate the table
INSERT INTO person
(id, first_name, last_name, age)
VALUES
' at line 1