Turbo
Turbo

Reputation: 13

PHPmyadmin won't accept CREATE TABLE statement

I'm trying to use a simple CREATE TABLE statement to create a new table in my very first SQL-database. PHPmyadmin won't accept the code and gives me an error statement.

There doesn't appear to be anything wrong with the syntax of my SQL command. In fact, I receive the same error statement when I copy and past an example code from any internet tutorial to create a table.

this is my SQL command:

CREATE TABLE Guestbook(
  ID int AUTO_INCREMENT PRIMARY KEY NOT NULL,
  Name varchar(50) NOT NULL,
  Message TEXT NOT NULL,
  Date datetime,
  Sport varchar(30),
  Practicioner BOOLEAN default 0,
)

This is the error statement:

Static analysis:

3 errors were found during analysis.

A symbol name was expected! (near "Name" at position 74)
Unexpected beginning of statement. (near "50" at position 87)
Unrecognized statement type. (near "NOT NULL" at position 91)
SQL query:

CREATE TABLE Guestbook( ID int AUTO_INCREMENT PRIMARY KEY NOT NULL,       Name varchar(50) NOT NULL, Message TEXT NOT NULL, Date datetime, Sport     varchar(30), Practicioner BOOLEAN default 0, )

MySQL said: Documentation

#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     ')' at line 8

I can't imagine why this won't work. I'd like to be able to use to command line in phpMyadmin. and this seems pretty straigtht forward. Yet I've been fiddling around with it for ages and I can't figure out how to create even the simplest possible table.

Can anyone help me out?

Upvotes: 1

Views: 1063

Answers (1)

Dekel
Dekel

Reputation: 62676

You should remove the last comma in your CREATE statement:

CREATE TABLE Guestbook(
  ID int AUTO_INCREMENT PRIMARY KEY NOT NULL,
  Name varchar(50) NOT NULL,
  Message TEXT NOT NULL,
  Date datetime,
  Sport varchar(30),
  Practicioner BOOLEAN default 0
)

Upvotes: 2

Related Questions