1
使用MySQL 5.5,我能夠單獨執行CREATE TABLE
和INSERT
查詢,但是當我把它們放在一個.sql
腳本我收到以下錯誤兩次:無法執行.SQL腳本,但查詢單獨工作
錯誤1064(42000):您的SQL語法錯誤;
我試着按照這裏推薦的使用GO語句(SQL script doesnt work but individual queries work),但沒有運氣。
這裏是我現在的工作腳本感謝評論:
-- 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
另一個問題是SQL Server,而不是MySQL。 – Barmar
Uhm,'GO'不適用於MySQL,對MSSQL來說不是那種東西嗎? – Darwind
什麼是你得到的完整的錯誤信息? – Barmar