Search code examples
mysqldatabasecreate-table

I cant solve error in database


Possible Duplicate:
I have mistake in database

create table Ticket (
ticket_id integer not null primary key,
AirlineName varchar not null,
CustomerName varchar,
fromCity varchar,
toCity varchar,
fltNo integer,
TicketDate date,
Dtime TIME,
Atime time,
price integer);

Please help me, I can't find the error. the program is my sql, and this is the error

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 'not null, CustomerName varchar, fromCity varchar, toCity varchar, fltNo inte' at line 3


Solution

  • Now that I know it's MySQL:

    Your varchars should have lengths (and phpMyAdmin appears to use INT instead of integer, but both seem to be valid)

    CREATE TABLE Ticket(
    ticket_id INT PRIMARY KEY ,
    AirlineName VARCHAR( 255 ) NOT NULL ,
    CustomerName VARCHAR( 255 ) ,
    fromCity VARCHAR( 255 ) ,
    toCity VARCHAR( 255 ) ,
    fltNo INT,
    TicketDate DATE,
    Dtime TIME,
    Atime TIME,
    price INT
    );