shashank shashank - 1 year ago 140
MySQL Question

MYSQL error on cmd pasting

I am on a mac system . I have mysql installed . I wanted to create a table in a database named ticket_system

create table ticket_system.Train
Name char(10),
source char(10),
destination char(10),
start_time DATE,
reach_time DATE,
traveltime NUMBER(10),
distance NUMBER(10),
class NUMBER(10),
days NUMBER(10),
type char(10)

I wrote the code in sublime for connivence. And then tried pasting in the terminal. I get this error

ERROR 1064 (42000): 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 'NUMBER(10) PRIMARY KEY, Name char(10), source char(10), destination char(10), st' at line 1

it seem like my code somehow ended after st which was supposed to be start_time.

On pasting I was asked by iterm2 that there are tabs and how would you like to treat them as and I selected 4 spaces which was default.

What can be the reason for this error and what is the best method to practise mysql for my exam? Please let me know the alternatives also if this is not a convenient way.

Answer Source

MySQL does not have a number() data type. Use INT or a similar data type which is appropriate for auto incrementation.

If you need a fixed-point data type for numbers like 13.98 then use numeric().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download