I am trying to finish up my lab and i cant find the missing right parenthesis that it is saying that i am missing. I have finished the course table and it is all correct but i am getting an error on every other table could someone please help?
CREATE TABLE COURSE(
CRS_CODE VARCHAR(8) NOT NULL,
CRS_DESCRIPTION VARCHAR(35) NOT NULL,
CRS_CREDIT INTEGER DEFAULT 4 NOT NULL CHECK(CRS_CREDIT IN (1,2,3,4)),
PRIMARY KEY (CRS_CODE));
CREATE TABLE CLASS (
CRS_CODE VARCHAR(8) NOT NULL,
CLASS_CODE INTEGER (5) NOT NULL,
CHECK (CLASS_SECTION IN (0,1,2,3,4,5,6,7,8)),
CLASS_TIME VARCHAR(25) NOT NULL,
CLASS_ROOM CHAR(6),
CRS_CODE REFERENCES COURSE(CRS_CODE),
PRIMARY KEY (CLASS_CODE));
CREATE TABLE STUDENT(
STU_NUM INTEGER NOT NULL,
STU_LNAME VARCHAR(25) NOT NULL,
STU_FNAME VARCHAR(20) NOT NULL,
STU_INIT VARCHAR(1),
STU_DOB DATE,
STU_HRS INTEGER DEFAULT 0 CHECK (STU_HRS>=0 AND STU_HRS<1000),
STU_CLASS VARCHAR(2) CHECK (STU_CLASS IN ('Fr', 'So', 'Jr', 'Sr', 'Gr')),
STU_GPA DECIMAL(3,2) DEFAULT 0.00 CHECK (STU_GPA BETWEEN 0.00 AND 4.00),
STU_PHONE INTEGER(4),
PRIMARY KEY (STU_NUM));
CREATE TABLE ENROLL(
ENROLL_GRADE VARCHAR(1) DEFAULT 'Z' CHECK (ENROLL_GRADE IN('A','B','C','D','F','I','W','Z')),
STU_NUM INTEGER REFERENCES STUDENT(STU_NUM),
CLASS_CODE INTEGER (5) REFERENCES CLASS(CLASS_CODE));
This is too long for a comment.
Part of the purpose of labs is so you learn how to debug your code. Trial and error in the academic environment is much more efficient than in the "real world".
To debug, simplify! The first question is: Where does the error occur? Does it occur in the first table creation? In the second? And so on. You can determine this by creating the first table. Then the first two tables, and so on.
Once you have the table, you may be able to quickly spot the error. If not, you can comment out the column definitions one at a time.
When you do this, you will find at least two errors:
Also, if you are using Oracle, the recommended type for strings is
varchar2(), notvarchar().