mysqlsh -h localhost -u mixtape-dating -p -f setup.sql
和setup.sql由
USE MixtapeDating;
-- Tables
-- The Playlist table gets featured on the front page.
CREATE TABLE Playlist (
Id INT PRIMARY KEY AUTO_INCREMENT,
Title VARCHAR(255),
Email VARCHAR(255),
CreatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- The PlaylistItem gets featured at /playlist/:id
CREATE TABLE PlaylistItem (
Id INT PRIMARY KEY AUTO_INCREMENT,
PlaylistId INT,
Title VARCHAR(255),
Link VARCHAR(255)
);
-- Stored Procedures
-- Insert playlist
CREATE PROCEDURE InsertPlaylist
(
IN Title VARCHAR(255),
IN Email VARCHAR(255),
OUT PlaylistId INT
)
BEGIN
INSERT INTO Playlist (Title, Email)
VALUES (@Title, @Email);
SELECT LAST_INSERT_ID() AS @PlaylistId;
END
CREATE PROCEDURE InsertPlaylistItem
(
IN PlaylistId INT,
IN Title VARCHAR(255),
IN Link VARCHAR(255)
)
BEGIN
INSERT INTO PlaylistItem (PlaylistId, Title, Link)
VALUES (@PlaylistId, @Title, @Link);
END
-- Fetch all playlists
CREATE PROCEDURE GetPlaylists
BEGIN
SELECT Id, Title, Email
FROM Playlist;
END
-- Fetch all playlist items for a playlist
CREATE PROCEDURE GetPlaylist
(IN Id INT)
BEGIN
SELECT PlaylistId, Id, Title, Link
FROM PlaylistItem
WHERE Id = @Id;
END
,但我得到了以下錯誤:
C:\Users\moore\Desktop\playlist-dating>mysqlsh -h localhost -u mixtape-dating -p -f setup.sql
Enter password: ****************
SyntaxError: Unexpected identifier at setup.sql:1:4
in USE MixtapeDating;
^^^^^^^^^^^^^
我在做什麼錯?
不太熟悉的Windows命令提示符,但如果你使用的是Windows 10,你可以使用Ubuntu的子系統。 – Goose
爲什麼就不能安裝MySQL工作臺(https://dev.mysql.com/downloads/file/?id=468295)和像老闆一樣調試SQL文件? (: – num8er