I am new to SQL and I am having trouble with the foreign keys in the CourseEnrollments table.
I keep receiving an error report - ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis *Cause: *Action:
It appears that all the commas and parenthesis are in place.
Create Table Students
(
StudentID INT NOT NULL,
Lastname VARCHAR2(25),
Firstname VARCHAR2(20),
Email VARCHAR2(40),
Enrollmentdate DATE,
CONSTRAINT student_pk PRIMARY KEY (StudentID)
);
/* This is the creation of the Students table */
Create Table Faculty
(
FacultyID INT NOT NULL,
Lastname VARCHAR2(25),
Firstname VARCHAR2(20),
Email VARCHAR2(40),
Hiredate DATE,
CONSTRAINT faculty_pk PRIMARY KEY (FacultyID)
);
/* This is the creation of the Faculty table */
Create Table Courses
(
CourseID INT NOT NULL,
"Subject (e.g. SDEV)" VARCHAR2(20),
"Catalognbr (e.g. 350)" NUMBER,
"Title (e.g. Database Security)" VARCHAR2(40),
CONSTRAINT course_pk PRIMARY KEY (CourseID)
);
/* This is the creation of the Courses table */
Create Table CourseEnrollments
(
EnrollmentID INT NOT NULL,
CONSTRAINT fk_Students
FOREIGN KEY (StudentID)
REFERENCES Students(StudentID)
CONSTRAINT fk_Faculty
FOREIGN KEY (FacultyID)
REFERENCES Faculty(FacultyID)
CONSTRAINT fk_Courses
FOREIGN KEY (CourseID)
REFERENCES Courses(CourseID)
CONSTRAINT enrollment_pk PRIMARY KEY (EnrollmentID)
);
select "Title (e.g Database security)" from COURSES>>> and it'll fail, because I didnt put a dot in "e.g." and didn't use capital "S" in "Security"? Such a table is a nightmare. There's a COMMENT you can use for any column, e.g.comment on column courses.title is 'e.g. database security';- Littlefoot