En-Motion
En-Motion

Reputation: 919

phpMyadmin - Error #1064

When trying to create this table in my db, I get an error:

#1064 - 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 'unsigned NOT NULL default '0', PRIMARY KEY (reminder_id), KEY reminder_id (rem' at line 5

CREATE TABLE reminder_events (
reminder_id bigint(20) unsigned NOT NULL auto_increment,
reminder_name varchar(255) NOT NULL default '',
reminder_desc text,
reminder_date varchar(8) unsigned NOT NULL default '0',
PRIMARY KEY (reminder_id),
KEY reminder_id (reminder_id)
) TYPE=MyISAM;

Can anyone see what I'm doing wrong?

Upvotes: 2

Views: 41058

Answers (3)

Shailesh
Shailesh

Reputation: 11

Write ENGINE instead of TYPE

CREATE TABLE reminder_events (
reminder_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
reminder_name VARCHAR(255) NOT NULL DEFAULT '',
reminder_desc TEXT,
reminder_date VARCHAR(8) NOT NULL DEFAULT '0',
PRIMARY KEY (reminder_id),
KEY reminder_id (reminder_id)
) ENGINE=MYISAM;

Upvotes: 0

John Parker
John Parker

Reputation: 54425

The problem is that you're trying to define a text field (varchar) as being unsigned, which is something that can only apply to a numerical field.

i.e.: "reminder_date varchar(8) unsigned NOT NULL default '0'," makes no sense.

However, as the field is called "reminder_date", I'm guessing you're attempting to store a date, in which case you really want to use MySQLs DATE field type.

e.g.: "reminder_date DATE NOT NULL,"

Additionally, if you're going to want to search on any of these fields, you should also add some indexes to speed up the searches. So, if you wanted to be able to search on the name and date, you could use:

CREATE TABLE reminder_events (
reminder_id bigint(20) unsigned NOT NULL auto_increment,
reminder_name varchar(255) NOT NULL DEFAULT '',
reminder_desc text,
reminder_date DATE NOT NULL,
PRIMARY KEY (reminder_id),
KEY reminder_id (reminder_id),
KEY reminder_name (reminder_name),
KEY reminder_date (reminder_date)
) TYPE=MyISAM;

Upvotes: 2

UltraInstinct
UltraInstinct

Reputation: 44434

Just remove unsigned.

CREATE TABLE reminder_events (
reminder_id bigint(20) unsigned NOT NULL auto_increment,
reminder_name varchar(255) NOT NULL default '',
reminder_desc text,
reminder_date varchar(8) NOT NULL default '0',
PRIMARY KEY (reminder_id),
KEY reminder_id (reminder_id)
) TYPE=MyISAM;

Upvotes: 2

Related Questions