The given SQL creates an Album and Song tables. The SHOW COLUMNS queries show information about the
Fantastic news! We've Found the answer you've been seeking!
Question:
The given SQL creates an Album and Song tables. The SHOW COLUMNS queries show information about the Album and Song table columns.
Modify the two CREATE TABLE statements. Add a primary key constraint to the Album table's ID column. Add a primary key constraint to the Song table's ID column, and add a foreign key constraint so the AlbumID column refers to the Album table's ID column.
-- Add a primary key
CREATE TABLE Album (
ID INT,
Title VARCHAR(60),
ReleaseYear INT
PRIMARY KEY (ID)
);
-- Add primary and foriegn keys
CREATE TABLE Song (
ID INT,
Title VARCHAR(60),
Artist VARCHAR(60),
AlbumID INT
PRIMARY KEY (ID),
FOREIGN KEY (AlbumID)
);
SHOW COLUMNS
FROM Album;
SHOW COLUMNS
FROM Song;
ERROR 1064 (42000) at line 2: 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 '(ID) )' at line 5
What is going wrong please?
Related Book For
Posted Date: