178k views
14 votes
The given SQL creates a Movie table with an auto-incrementing ID column. Write a single INSERT statement immediately after the CREATE TABLE statement that inserts the following movies:

Title Rating Release Date
Raiders of the Lost Ark PG June 15, 1981
The Godfather R March 24, 1972
The Pursuit of Happyness PG-13 December 15, 2006
Note that dates above need to be converted into YYYY-MM-DD format in the INSERT statement. Run your solution and verify the movies in the result table have the auto-assigned IDs 1, 2, and 3.
CREATE TABLE Movie (
ID INT AUTO_INCREMENT,
Title VARCHAR(100),
Rating CHAR(5) CHECK (Rating IN ('G', 'PG', 'PG-13', 'R')),
ReleaseDate DATE,
PRIMARY KEY (ID)
);
-- Write your INSERT statement here:

User Smaranjit
by
5.0k points

1 Answer

12 votes

Answer:

INSERT INTO Movie(Title,Rating,ReleaseDate)

VALUES("Raiders of the Lost ArkPG",'PG',DATE '1981-06-15'),

("The Godfaher",'R',DATE '1972-03-24'),

("The Pursuit of Happyness",'PG-13',DATE '2006-12-15');

Step-by-step explanation:

The SQL statement uses the "INSERT" clause to added data to the movie table. It uses the single insert statement to add multiple movies by separating the movies in a comma and their details in parenthesis.

User Wvp
by
5.0k points