FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Problem with creating a database -- help :(





davidv
Code:
DROP DATABASE IF EXISTS films;
CREATE DATABASE films;
USE films;

/* Movies table */
CREATE TABLE movies (
   movie_id INT UNSIGNED AUTO_INCREMENT,
   title VARCHAR(50),
   genre ENUM('Comedy','Crime','Horror','Drama','Mystery','Action'),
   year_published SMALLINT,
   year_added SMALLINT,
   rating VARCHAR(10),
   viewed BOOLEAN NOT NULL DEFAULT 0,
   finished BOOLEAN NOT NULL DEFAULT 0,
   primary key (movie_id)
)

/* TV Shows tables */
CREATE TABLE tv_shows (
   show_id INT UNSIGNED AUTO_INCREMENT,
   title VARCHAR(50),
   genre ENUM('Comedy','Crime','Horror','Drama','Mystery','Action'),
   rating VARCHAR(10),
   year_added SMALLINT,
   viewed BOOLEAN NOT NULL DEFAULT 0,
   finished BOOLEAN NOT NULL DEFAULT 0,
   PRIMARY KEY (show_id)
) ENGINE = InnoDB;

CREATE TABLE tv_seasons (
   season_id INT UNSIGNED AUTO_INCREMENT,
   title VARCHAR(50),
   viewed BOOLEAN NOT NULL DEFAULT 0,
   finished BOOLEAN NOT NULL DEFAULT 0,
   PRIMARY KEY (season_id),
   FOREIGN KEY (season_id) REFERENCES tv_shows (show_id)
) ENGINE = InnoDB;

CREATE TABLE tv_episodes (
   episode_id INT UNSIGNED AUTO_INCREMENT,
   title VARCHAR(50),
   viewed BOOLEAN NOT NULL DEFAULT 0,
   finished BOOLEAN NOT NULL DEFAULT 0,
   PRIMARY KEY (episode_id),
   FOREIGN KEY (episode_id) REFERENCES tv_seasons (season_id)
) ENGINE = InnoDB;


ERROR:

Code:
C:\Documents and Settings\x>mysql -b -u root -p < create_film_db.sql
Enter password: ******
ERROR 1064 (42000) at line 6: 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 TABLE tv_shows (
        show_id INT UNSIGNED AUTO_INCREMENT,
        title VARCHAR(50)' at line 14


I don't know what the problem is, can anyone spot it?
rjraaz
Your Code is missing ";" at line number 14, of creating table movies.

Put ";" at line number 14.

I hope you can understand that if not ask it again.
saberlivre
I think rjraaz is correct. You must complete the CREATE TABLE statement (table movies) with the line

) ENGINE = InnoDB;
davidv
BLAH! Silly syntax errors. Thanks guys.
macky
Alternatively you can also use MySQL GUI TOOLS such as PHPmyADMIN or MySQL Workbench, there you don't need to check out the semicolon but of course it's a good habit to practice the right way.

I just suggest this so every time you encounter problems, you may paste and try to run on different database administration tool so you can figure out what's the problem.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.