CREATE TABLE Actor (
actor_id INT AUTO_INCREMENT PRIMARY KEY,
actor_name VARCHAR(255) NOT NULL,
actor_gender ENUM('M', 'F', 'Other') NOT NULL,
actor_birthdate DATE NOT NULL
);
CREATE TABLE Director (
director_id INT AUTO_INCREMENT PRIMARY KEY,
director_name VARCHAR(255) NOT NULL,
director_birthdate DATE NOT NULL
);
CREATE TABLE Movie (
movie_id INT AUTO_INCREMENT PRIMARY KEY,
movie_title VARCHAR(255) NOT NULL,
movie_release_date DATE NOT NULL,
movie_runtime INT NOT NULL,
movie_rating DECIMAL(3,1) NOT NULL,
genre_id INT NOT NULL,
FOREIGN KEY (genre_id) REFERENCES Genre(genre_id)
);
CREATE TABLE Genre (
genre_id INT AUTO_INCREMENT PRIMARY KEY,
genre_name VARCHAR(255) NOT NULL
);
CREATE TABLE MovieCast (
movie_id INT NOT NULL,
actor_id INT NOT NULL,
PRIMARY KEY (movie_id, actor_id),
FOREIGN KEY (movie_id) REFERENCES Movie(movie_id),
FOREIGN KEY (actor_id) REFERENCES Actor(actor_id)
);
CREATE TABLE DirectorOf (
movie_id INT NOT NULL,
director_id INT NOT NULL,
PRIMARY KEY (movie_id, director_id),
FOREIGN KEY (movie_id) REFERENCES Movie(movie_id),
FOREIGN KEY (director_id) REFERENCES Director(director_id)
);
我不知道错误在哪里
1条答案
按热度按时间5f0d552i1#
在Oracle中,
AUTO_INCREMENT
和ENUM
都不是有效语法。您需要:fiddle