Question:
Problems with SQL commands to Create a table?
EboniDimplz
2007-06-03 15:50:38 UTC
I need the SQL code that will create a table structure for a table named EMP_1. This table is a subset of the EMPLOYEE table.
The basic EMP_1 table structure is:
EMP_NUM CHAR(3),
EMP_LNAME VARCHAR(15),
EMP_FNAME VARCHAR(15),
EMP_INITIAL CHAR(1),
EMPL_HIREDATE DATE,
JOB_CODE CHAR(3).
JOB_CODE is the FK to JOB.

I have entered this command like 15 times and I keep getting the error that a line is missing right parenthesis, and I put it in there. Can someone tell me how to format this correctly?
Three answers:
anonymous
2007-06-03 16:28:14 UTC
This will work in MySQL:



CREATE TABLE IF NOT EXISTS EMP_1

(

EMP_NUM NOT CHAR(3) NOT NULL,

EMP_LNAME VARCHAR(15),

EMP_FNAME VARCHAR(15),

EMP_INITIAL CHAR(1),

EMPL_HIREDATE DATE,

JOB_CODE CHAR(3) NOT NULL

PRIMARY KEY(EMP_NUM),

FOREIGN KEY(JOB_CODE) REFERENCES JOB (JOB_CODE)

)
anonymous
2007-06-03 16:00:32 UTC
what exactly do you mean by structure? heres the sql's great tutorial on tables and everything else.. http://dev.mysql.com/doc/refman/5.0/en/creating-tables.html
?
2016-05-20 09:08:09 UTC
If you used the "insert" statement on the students table, did you use "commit;" afterward?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...