worldperseus
New member
- Local time
- Yesterday, 17:15
- Joined
- Feb 11, 2010
- Messages
- 1
Hi
I Execute the following sql statement successfully for a Access Database.
But Finally I Get Error message(Syntax error in CONSTRAINT clause.) on this satement that is at the end of my execution list.
And I don't know Why?
Please Help me on how to establish a relation in access database through sql statement?
I Execute the following sql statement successfully for a Access Database.
Code:
CREATE TABLE Scores (
StudentCode Text(9) NOT NULL,
CourseCode Text(7) NOT NULL,
SemesterCode Text(3) NOT NULL,
Score Double
);
CREATE TABLE Courses (
CourseCode Text(7) NOT NULL,
CourseName Memo NOT NULL,
CourseTypeID Integer NOT NULL,
CourseCategoryID Integer NOT NULL
);
ALTER TABLE Scores ADD CONSTRAINT PK_Grades
PRIMARY KEY (StudentCode, CourseCode, SemesterCode);
ALTER TABLE Courses ADD CONSTRAINT PK_Courses
PRIMARY KEY (CourseCode);
ALTER TABLE Courses
ADD CONSTRAINT UQ_Courses_CourseCode UNIQUE (CourseCode);
But Finally I Get Error message(Syntax error in CONSTRAINT clause.) on this satement that is at the end of my execution list.
Code:
ALTER TABLE Scores ADD CONSTRAINT FK_Scores_Courses
FOREIGN KEY (CourseCode) REFERENCES Courses (CourseCode)
ON UPDATE CASCADE;
Please Help me on how to establish a relation in access database through sql statement?