发布网友 发布时间:2022-04-22 15:43
共1个回答
热心网友 时间:2022-04-09 12:43
CREATE TABLE [学生] (
[学号] [int] NOT NULL ,
[姓名] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[性别] [nvarchar] (1) COLLATE Chinese_PRC_CI_AS NULL ,
[系号] [int] NULL ,
[年龄] [int] NULL
) ON [PRIMARY]
CREATE TABLE [系表] (
[系号] [int] NOT NULL ,
[系名] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[系主任] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
ALTER TABLE [学生] ADD
CONSTRAINT [PK_学生] PRIMARY KEY CLUSTERED
(
[学号]
) ON [PRIMARY]
ALTER TABLE [系表] ADD
CONSTRAINT [PK_系表] PRIMARY KEY CLUSTERED
(
[系号]
) ON [PRIMARY]
ALTER TABLE [学生] ADD
CONSTRAINT [FK_学生_系表] FOREIGN KEY
(
[系号]
) REFERENCES [系表] (
[系号]
) ON DELETE CASCADE ON UPDATE CASCADE