Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to mySQL...error just creating table

Status
Not open for further replies.

jaybytez

Programmer
Jan 8, 2003
65
US
CREATE TABLE EMPLOYEE_TBL
(
EMP_ID VARCHAR2(9) NOT NULL,
LAST_NAME VARCHAR2(15) NOT NULL,
FIRST_NAME VARCHAR2(15) NOT NULL,
MIDDLE_NAME VARCHAR2(15),
ADDRESS VARCHAR2(30) NOT NULL,
CITY VARCHAR2(15) NOT NULL,
STATE CHAR(2) NOT NULL,
ZIP NUMBER(5) NOT NULL,
PHONE CHAR(10),
PAGER CHAR(10),
CONSTRAINT EMP_PK PRIMARY KEY (EMP_ID)
);

ERROR 1064: You have an error in your SQL syntax near 'VARCHAR2(9) NOT NUL
L,
LAST_NAME VARCHAR2(15) NOT NULL,
FIRS' at line 3
 
When I take VARCHAR2 and change it to VARCHAR:

CREATE TABLE EMPLOYEE_TBL
(
EMP_ID VARCHAR(9) NOT NULL,
LAST_NAME VARCHAR(15) NOT NULL,
FIRST_NAME VARCHAR(15) NOT NULL,
MIDDLE_NAME VARCHAR(15),
ADDRESS VARCHAR(30) NOT NULL,
CITY VARCHAR(15) NOT NULL,
STATE CHAR(2) NOT NULL,
ZIP NUMBER(5) NOT NULL,
PHONE CHAR(10),
PAGER CHAR(10),
CONSTRAINT EMP_PK PRIMARY KEY (EMP_ID)
);

ERROR 1064: You have an error in your SQL syntax near 'NUMBER(5) NOT NULL,
PHONE CHAR(10),
PAGER CHAR(10),
CONSTRAINT EMP_PK PRIMARY KE' at line 10

I am trying to work through examples in Teach Yourself SQL in 24 hours. Is MySQL that hard to learn? Not sure what I am doing wrong?

Thanks!
 
Change NUMBER(5) to MEDIUMINT(5), or, since it's a numeric code (possibly with leading zeroes?), CHAR(5)

-----
ALTER world DROP injustice, ADD peace;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top