我正在尝试在MS Access中运行包含多个CREATE TABLE
语句的脚本。
当我尝试一起运行脚本时,在第二个CREATE TABLE
上出现CREATE TABLE
语法错误,但是当我通过SQL验证程序单独运行每个CREATE TABLE
时,它们会通过成功。
通过将所有CREATE TABLE集中到一个脚本中,我在做什么错了?
CREATE TABLE MODEL (
ModelNum INT NOT NULL,
Capacity INT NOT NULL,
MaxRange INT NOT NULL,
CONSTRAINT ModelPK PRIMARY KEY(ModelNum)
);
CREATE TABLE AIRPLANE (
RegNum INT NOT NULL,
ModelNum INT NOT NULL,
CONSTRAINT AirplanePK PRIMARY KEY(RegNum),
CONSTRAINT AirplaneFK FOREIGN KEY(ModelNum) REFERENCES MODEL(ModelNum)
);
CREATE TABLE EMPLOYEE (
SSN INT NOT NULL,
EmpName VARCHAR(100) NOT NULL,
Phone INT NULL,
UnionMemberNum INT NULL,
CONSTRAINT EmployeePK PRIMARY KEY(SSN)
);
CREATE TABLE TECHNICIAN (
SSN INT NOT NULL,
Salary INT NOT NULL,
CONSTRAINT TechnicianPK PRIMARY KEY(SSN),
CONSTRAINT TechnicianFK FOREIGN KEY(SSN) REFERENCES EMPLOYEE(SSN)
);
CREATE TABLE TRAFFICCONTROLLER (
SSN INT NOT NULL,
DateOfTraining DATE NULL,
CONSTRAINT TrafficControllerPK1 PRIMARY KEY(SSN),
CONSTRAINT TrafficControllerFK1 FOREIGN KEY(SSN) REFERENCES EMPLOYEE(SSN)
);
CREATE TABLE EXPERT(
SSN INT NOT NULL,
ModelNum INT NOT NULL,
CONSTRAINT ExpertPK1 PRIMARY KEY(SSN),
CONSTRAINT ExpertFK1 FOREIGN KEY(ModelNum) REFERENCES AIRPLANE(ModelNum)
);
CREATE TABLE TEST(
Test_Num INT NOT NULL,
TestName VARCHAR(100) NOT NULL,
MaxScore INT NOT NULL,
CONSTRAINT TestPK PRIMARY KEY(Test_Num)
);
CREATE TABLE TESTEVENTS(
RegNum INT NOT NULL,
Test_Num INT NOT NULL,
SSN INT NOT NULL,
TestDate DATE NOT NULL,
Score INT NULL,
CONSTRAINT TestEventsPK1 PRIMARY KEY(RegNum),
CONSTRAINT TestEventsFK1 FOREIGN KEY(RegNum) REFERENCES AIRPLANE(RegNum),
CONSTRAINT TestEventsPK2 PRIMARY KEY(Test_Num),
CONSTRAINT TestEventsFK2 FOREIGN KEY(Test_Num) REFERENCES TEST(Test_Num),
CONSTRAINT TestEventsPK3 PRIMARY KEY(SSN),
CONSTRAINT TestEventsFK3 FOREIGN KEY(SSN) REFERENCES TECHNICIAN(SSN),
CONSTRAINT TestEventsPK4 PRIMARY KEY(TestDate)
);
答案 0 :(得分:0)
MS Access一次仅支持一个语句。