Joel Jr Rudinas
Joel Jr Rudinas

Reputation: 23

Creating a table generates Error Code 1064

I am stuck with Error Code 1604 trying to create a table. The code goes like this:

USE Rudinas; 
CREATE TABLE clan (
first_name VARCHAR(30) NOT NULL, 
last_name VARCHAR(30) NOT NULL, 
city VARCHAR(30) NOT NULL,
country VARCHAR(30) NOT NULL,
zip MEDIUMINT UNSIGNED NOT NULL, 
birth_date DATE NOT NULL
sex ENUM("M", "F") NOT NULL,
clan_belong ENUM('EU', 'ASIAPAC', 'USA', 'SLO') NOT NULL,
date_entered TIMESTAMP,
relative_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); 

enter image description here

How can I get this table to run?

Upvotes: 1

Views: 179

Answers (3)

phpforcoders
phpforcoders

Reputation: 326

Use comma(,) after birth_date DATE NOT NULL

CREATE TABLE clan (
first_name VARCHAR(30) NOT NULL, 
last_name VARCHAR(30) NOT NULL, 
city VARCHAR(30) NOT NULL,
country VARCHAR(30) NOT NULL,
zip MEDIUMINT UNSIGNED NOT NULL, 
birth_date DATE NOT NULL,
sex ENUM("M", "F") NOT NULL,
clan_belong ENUM('EU', 'ASIAPAC', 'USA', 'SLO') NOT NULL,
date_entered TIMESTAMP,
relative_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); 

Upvotes: 2

lc.
lc.

Reputation: 116458

There will be something wrong with your statement somewhere. Unfortunately with the smallest of errors the human brain will sometimes autocorrect and it takes some time/energy/luck to discover the problem.

One thing I would suggest is to start paring your statement down until it works, then build it back up again. For example, start by removing half the columns, then add the others back until it either breaks (the problem is here) or it works (you didn't make the same mistake this time). This is in fact a good approach for debugging most code, especially if you cannot step through.

Stepping away for a few minutes and coming back can also help, as can utilizing a second pair of eyes.

In this case you're simply missing a comma:

birth_date DATE NOT NULL
--                     ^^^

Upvotes: 1

Arsalan Akhtar
Arsalan Akhtar

Reputation: 389

you just missed the , before sex column.

CREATE TABLE clan(
first_name VARCHAR(30) NOT NULL,
last_name VARCHAR(30) NOT NULL,
city VARCHAR(30) NOT NULL,
country VARCHAR(30) NOT NULL,
zip MEDIUMINT UNSIGNED NOT NULL,
birth_date DATE NOT NULL ,
sex ENUM("M", "F") NOT NULL,
clan_belong ENUM('EU', 'ASIAPAC', 'USA', 'SLO') NOT NULL,
date_entered TIMESTAMP,
relative_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
);

Upvotes: 1

Related Questions