-4

When creating a table as follows

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);

I get the following 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

What might cause this and how to I solve it?

Bart
  • 19,692
  • 7
  • 68
  • 77
tara7el
  • 21
  • 2
  • 2
    Uhm... what "mistake" do you have? – Eric J. Jul 26 '12 at 17:55
  • Where to start... what's the mistake? What's the problem? What did you try? – LittleBobbyTables - Au Revoir Jul 26 '12 at 17:55
  • what kind of DB ? what error ? – Nir Alfasi Jul 26 '12 at 17:55
  • 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 – tara7el Jul 26 '12 at 18:12
  • sorry for late < but this is the error – tara7el Jul 26 '12 at 18:12
  • Take a look at the MySQL examples: http://dev.mysql.com/doc/refman/5.0/en/creating-tables.html Your `varchar` columns need to have a length specification, such as `varchar(50)` for 50 characters. As a hint going forward, whenever MySQL indicates where you have a syntax problem, the issues is _just_ before where it tells you. The reason is because it failed to parse when it got to a certain point because you made a mistake immediately before that point. – David Jul 26 '12 at 18:30
  • Good edit. I've voted to reopen. – James Webster Jul 26 '12 at 18:32
  • @JamesWebster Yeah, but it seems [the dupe](http://stackoverflow.com/questions/11675565/i-cant-solve-error-in-database) now has answers making my work redundant. The OP should really not post dupes. – Bart Jul 26 '12 at 18:33

1 Answers1

0
create table Ticket (
ticket_id INT NOT NULL 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);
Shee
  • 1,875
  • 2
  • 14
  • 16