use master
go
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'网络考试系统')
DROP DATABASE [网络考试系统]
GO
CREATE DATABASE [网络考试系统]
GO
use [网络考试系统]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_考生主观题作答表_主观题信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[考生主观题作答表] DROP CONSTRAINT FK_考生主观题作答表_主观题信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_客观题临时表_客观题信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[客观题临时表] DROP CONSTRAINT FK_客观题临时表_客观题信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_成绩信息表_教师信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[成绩信息表] DROP CONSTRAINT FK_成绩信息表_教师信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_客观题信息表_管理人员信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[客观题信息表] DROP CONSTRAINT FK_客观题信息表_管理人员信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_主观题信息表_管理人员信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[主观题信息表] DROP CONSTRAINT FK_主观题信息表_管理人员信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_成绩信息表_考生信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[成绩信息表] DROP CONSTRAINT FK_成绩信息表_考生信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_考生主观题作答表_考生信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[考生主观题作答表] DROP CONSTRAINT FK_考生主观题作答表_考生信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_客观题临时表_考生信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[客观题临时表] DROP CONSTRAINT FK_客观题临时表_考生信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_成绩信息表_考试信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[成绩信息表] DROP CONSTRAINT FK_成绩信息表_考试信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[主观题信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[主观题信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[客观题临时表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[客观题临时表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[客观题信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[客观题信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[成绩信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[成绩信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[教师信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[教师信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[管理人员信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[管理人员信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[考生主观题作答表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[考生主观题作答表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[考生信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[考生信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[考试信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[考试信息表]
GO
CREATE TABLE [dbo].[主观题信息表] (
[考题号] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[题目内容] [text] COLLATE Chinese_PRC_CI_AS NOT NULL ,
[答案] [text] COLLATE Chinese_PRC_CI_AS NOT NULL ,
[难度系数] [char] (1) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[入库时间] [datetime] NOT NULL ,
[录入人员ID] [char] (6) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[客观题临时表] (
[ID自增] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[考生号] [char] (6) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[考题号] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[�