用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - sql代码库

建表

2017-12-22 作者:柯侧耳倾听者举报

[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


分享到:
更多

网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。