[sql]代码库
USE [st_db]
GO
/****** Object: Table [dbo].[s] Script Date: 12/19/2017 11:08:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[s](
[sno] [char](10) NOT NULL,
[sname] [char](8) NULL,
[ssex] [char](2) NULL,
[sage] [int] NULL,
[sdept] [char](2) NULL,
PRIMARY KEY CLUSTERED
(
[sno] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Deptage] Script Date: 12/19/2017 11:08:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Deptage](
[Ddept] [char](20) NULL,
[Dage] [smallint] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[c] Script Date: 12/19/2017 11:08:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[c](
[cno] [char](10) NOT NULL,
[cname] [char](20) NULL,
[cpno] [char](10) NULL,
[ccredit] [float] NULL,
PRIMARY KEY CLUSTERED
(
[cno] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[sc] Script Date: 12/19/2017 11:08:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[sc](
[sno] [char](10) NOT NULL,
[cno] [char](10) NOT NULL,
[grade] [int] NULL,
PRIMARY KEY CLUSTERED
(
[sno] ASC,
[cno] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Check [CK__s__sage__023D5A04] Script Date: 12/19/2017 11:08:09 ******/
ALTER TABLE [dbo].[s] WITH CHECK ADD CHECK (([sage]>=(17) AND [sage]<=(40)))
GO
/****** Object: Check [CK__s__ssex__014935CB] Script Date: 12/19/2017 11:08:09 ******/
ALTER TABLE [dbo].[s] WITH CHECK ADD CHECK (([ssex]='女' OR [ssex]='男'))
GO
/****** Object: ForeignKey [FK__sc__cno__0BC6C43E] Script Date: 12/19/2017 11:08:09 ******/
ALTER TABLE [dbo].[sc] WITH CHECK ADD FOREIGN KEY([cno])
REFERENCES [dbo].[c] ([cno])
GO
/****** Object: ForeignKey [FK__sc__sno__0AD2A005] Script Date: 12/19/2017 11:08:09 ******/
ALTER TABLE [dbo].[sc] WITH CHECK ADD CONSTRAINT [FK__sc__sno__0AD2A005] FOREIGN KEY([sno])
REFERENCES [dbo].[s] ([sno])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[sc] CHECK CONSTRAINT [FK__sc__sno__0AD2A005]
GO
by: 发表于:2018-05-31 11:00:03 顶(1) | 踩(1) 回复
??
回复评论