0

What is the problem with the following SQL statement:

create table teamstats (name varchar(10) not null,pos varchar(3) not null,ab numeric(3) not null,hits numberic(4) not null,walks varchar(5) not null,singles varchar(7) not null,doubles varchar7) not null,triples varchar(7) not null,hr numeric(2) not null,so varchar(2) not null);

and I get:

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 'numberic(4) not null,walks varchar(5) not nul l,singles varchar(7) not null,doubl' at line 1

1
  • numberic is not a data type.
    – G-Nugget
    Feb 13, 2013 at 18:55

4 Answers 4

2

You have two errors in your SQL:

  1. hits numberic(4) not null => numberic is not a valid data type

  2. doubles varchar7) not null => you forgot to open the parenthesis in varchar

This is the correct syntax:

create table teamstats
(
    name varchar(10) not null,
    pos varchar(3) not null,
    ab numeric(3) not null,
    hits numeric(4) not null,
    walks varchar(5) not null,
    singles varchar(7) not null,
    doubles varchar(7) not null,
    triples varchar(7) not null,
    hr numeric(2) not null,
    so varchar(2) not null
);

Here's the SQL Fiddle: http://sqlfiddle.com/#!2/261351

2
  • What is the key in this table?
    – Cratylus
    Feb 13, 2013 at 18:57
  • Actually there's no key defined for the table. Feb 13, 2013 at 19:00
2

Typo #1

 doubles varchar7)

Should be

 doubles varchar(7)

Typo #2

numberic

should be

numeric
1

Maybe change numberic to numeric

1

numeric is misspelled as numberic; that prevents MySQL from detecting it as a data type, and it doesn't know how to proceed. You also forgot your open parenthesis in the doubles column:

doubles varchar(7)

Not the answer you're looking for? Browse other questions tagged or ask your own question.