CREATE DATABASE testGOUSE testGOCREATE TABLE 系表(DEPTNO INT PRIMARY KEY, DNAME CHAR(20) NOT NULL)GOCREATE TABLE 學生資訊表(SNO INT NOT NULL PRIMARY KEY, SNAME CHAR(8) NOT NULL UNIQUE, SEX CHAR(2), DEPTNO INT REFERENCES 系表) GOCREATE TABLE 教師表(TNO INT NOT NULL PRIMARY KEY, TNAME CHAR(8) NOT NULL, DEPTNO INT REFERENCES 系表)GOCREATE TABLE 課程表(CNO INT NOT NULL PRIMARY KEY, CNAME CHAR(20) NOT NULL, TNO INT REFERENCES 教師表, CREDIT INT)GOCREATE TABLE 選課表(SNO INT NOT NULL REFERENCES 學生資訊表, CNO INT NOT NULL REFERENCES 課程表, GRADE INT, PRIMARY KEY(SNO,CNO))
CREATE DATABASE testGOUSE testGOCREATE TABLE 系表(DEPTNO INT PRIMARY KEY, DNAME CHAR(20) NOT NULL)GOCREATE TABLE 學生資訊表(SNO INT NOT NULL PRIMARY KEY, SNAME CHAR(8) NOT NULL UNIQUE, SEX CHAR(2), DEPTNO INT REFERENCES 系表) GOCREATE TABLE 教師表(TNO INT NOT NULL PRIMARY KEY, TNAME CHAR(8) NOT NULL, DEPTNO INT REFERENCES 系表)GOCREATE TABLE 課程表(CNO INT NOT NULL PRIMARY KEY, CNAME CHAR(20) NOT NULL, TNO INT REFERENCES 教師表, CREDIT INT)GOCREATE TABLE 選課表(SNO INT NOT NULL REFERENCES 學生資訊表, CNO INT NOT NULL REFERENCES 課程表, GRADE INT, PRIMARY KEY(SNO,CNO))