Petr Petrov
Petr Petrov

Reputation: 4452

Mysql: Couldn't create a table in MySql

I'm a new in databases and I have some problem with creating table

mysql> CREATE TABLE FILMS (
-> film_id INT NOT NULL AUTO_INCREMENT,
-> film_name VARCHAR(40) NOT NULL,
-> film_mark FLOAT NOT NULL,
-> PRIMARY_KEY (film_id)
-> );

Am getting below error.

ERROR 1064 (42000): 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 '( film_id ))' at line 5

Version of mysql

mysql  Ver 14.14 Distrib 5.7.19, for osx10.12 (x86_64) using  EditLine wrapper

Upvotes: 0

Views: 71

Answers (2)

Rida Helbawi
Rida Helbawi

Reputation: 11

  CREATE TABLE MyGuests (
  id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  firstname VARCHAR(30) NOT NULL,
  lastname VARCHAR(30) NOT NULL,
  email VARCHAR(50),
  reg_date TIMESTAMP
  )

this is an example. w3schools is a good place to learn mysql.

Upvotes: 0

Elumalai Kaliyaperumal
Elumalai Kaliyaperumal

Reputation: 1520

Change PRIMARY_KEY to PRIMARY KEY in your query.

Upvotes: 4

Related Questions