91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

創建原始數據庫——創建數據、創建表

發布時間:2020-06-04 21:53:28 來源:網絡 閱讀:612 作者:sky9890 欄目:關系型數據庫

書籍:數據庫系統原理與設計(第3版)——萬常選 廖國瓊等編著

任務驅動:由于找不到原始數據庫,只有從零開始創建數據庫、設計數據庫關系圖、輸入數據,為后面深入研究數據庫做好數據準備。

數據庫版本:SQL Server 2005

操作步驟:

1.創建數據庫源碼如下或是通過數據庫管理工具創建數據庫

USE [master]

GO

/****** 對象:  Database [ScoreDB]    腳本日期: 11/28/2018 21:44:34 ******/

CREATE DATABASE [ScoreDB] ON  PRIMARY 

( NAME = N'ScoreDB', FILENAME = N'D:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ScoreDB.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )

 LOG ON 

( NAME = N'ScoreDB_log', FILENAME = N'D:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ScoreDB_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)

 COLLATE Chinese_PRC_CI_AS

GO

EXEC dbo.sp_dbcmptlevel @dbname=N'ScoreDB', @new_cmptlevel=90

GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))

begin

EXEC [ScoreDB].[dbo].[sp_fulltext_database] @action = 'disable'

end

GO

ALTER DATABASE [ScoreDB] SET ANSI_NULL_DEFAULT OFF 

GO

ALTER DATABASE [ScoreDB] SET ANSI_NULLS OFF 

GO

ALTER DATABASE [ScoreDB] SET ANSI_PADDING OFF 

GO

ALTER DATABASE [ScoreDB] SET ANSI_WARNINGS OFF 

GO

ALTER DATABASE [ScoreDB] SET ARITHABORT OFF 

GO

ALTER DATABASE [ScoreDB] SET AUTO_CLOSE OFF 

GO

ALTER DATABASE [ScoreDB] SET AUTO_CREATE_STATISTICS ON 

GO

ALTER DATABASE [ScoreDB] SET AUTO_SHRINK OFF 

GO

ALTER DATABASE [ScoreDB] SET AUTO_UPDATE_STATISTICS ON 

GO

ALTER DATABASE [ScoreDB] SET CURSOR_CLOSE_ON_COMMIT OFF 

GO

ALTER DATABASE [ScoreDB] SET CURSOR_DEFAULT  GLOBAL 

GO

ALTER DATABASE [ScoreDB] SET CONCAT_NULL_YIELDS_NULL OFF 

GO

ALTER DATABASE [ScoreDB] SET NUMERIC_ROUNDABORT OFF 

GO

ALTER DATABASE [ScoreDB] SET QUOTED_IDENTIFIER OFF 

GO

ALTER DATABASE [ScoreDB] SET RECURSIVE_TRIGGERS OFF 

GO

ALTER DATABASE [ScoreDB] SET  ENABLE_BROKER 

GO

ALTER DATABASE [ScoreDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 

GO

ALTER DATABASE [ScoreDB] SET DATE_CORRELATION_OPTIMIZATION OFF 

GO

ALTER DATABASE [ScoreDB] SET TRUSTWORTHY OFF 

GO

ALTER DATABASE [ScoreDB] SET ALLOW_SNAPSHOT_ISOLATION OFF 

GO

ALTER DATABASE [ScoreDB] SET PARAMETERIZATION SIMPLE 

GO

ALTER DATABASE [ScoreDB] SET  READ_WRITE 

GO

ALTER DATABASE [ScoreDB] SET RECOVERY FULL 

GO

ALTER DATABASE [ScoreDB] SET  MULTI_USER 

GO

ALTER DATABASE [ScoreDB] SET PAGE_VERIFY CHECKSUM  

GO

ALTER DATABASE [ScoreDB] SET DB_CHAINING OFF 

2.創建表源碼如下或是通過數據庫管理工具創建表

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Class]') AND type in (N'U'))

BEGIN

CREATE TABLE [dbo].[Class](

[classNo] [char](6) NOT NULL,

[className] [varchar](30) NULL,

[institute] [varchar](30) NULL,

[grade] [smallint] NULL,

[classNum] [tinyint] NULL,

 CONSTRAINT [PK_Class] PRIMARY KEY CLUSTERED 

(

[classNo] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]

END

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Course]') AND type in (N'U'))

BEGIN

CREATE TABLE [dbo].[Course](

[courseNo] [char](3) NOT NULL,

[courseName] [varchar](30) NULL,

[creditHour] [numeric](18, 0) NULL,

[courseHour] [int] NULL,

[priorCourse] [char](3) NULL,

 CONSTRAINT [PK_Course] PRIMARY KEY CLUSTERED 

(

[courseNo] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]

END

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Term]') AND type in (N'U'))

BEGIN

CREATE TABLE [dbo].[Term](

[termNo] [char](3) NOT NULL,

[termName] [varchar](30) NULL,

[remarks] [varchar](50) NULL,

 CONSTRAINT [PK_Term] PRIMARY KEY CLUSTERED 

(

[termNo] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]

END

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Score]') AND type in (N'U'))

BEGIN

CREATE TABLE [dbo].[Score](

[studentNo] [char](7) NOT NULL,

[courseNo] [char](3) NOT NULL,

[termNo] [char](3) NOT NULL,

[score] [numeric](18, 0) NULL,

 CONSTRAINT [PK_Score] PRIMARY KEY CLUSTERED 

(

[studentNo] ASC,

[courseNo] ASC,

[termNo] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]

END

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Student]') AND type in (N'U'))

BEGIN

CREATE TABLE [dbo].[Student](

[studentNo] [char](7) NOT NULL,

[studentName] [varchar](20) NULL,

[sex] [char](2) NULL,

[birthday] [datetime] NULL,

[native] [varchar](20) NULL,

[nation] [varchar](30) NULL,

[classNo] [char](6) NOT NULL,

 CONSTRAINT [PK_Student_1] PRIMARY KEY CLUSTERED 

(

[studentNo] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]

END

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Course_Course]') AND parent_object_id = OBJECT_ID(N'[dbo].[Course]'))

ALTER TABLE [dbo].[Course]  WITH CHECK ADD  CONSTRAINT [FK_Course_Course] FOREIGN KEY([priorCourse])

REFERENCES [dbo].[Course] ([courseNo])

GO

ALTER TABLE [dbo].[Course] CHECK CONSTRAINT [FK_Course_Course]

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Score_Course]') AND parent_object_id = OBJECT_ID(N'[dbo].[Score]'))

ALTER TABLE [dbo].[Score]  WITH CHECK ADD  CONSTRAINT [FK_Score_Course] FOREIGN KEY([courseNo])

REFERENCES [dbo].[Course] ([courseNo])

GO

ALTER TABLE [dbo].[Score] CHECK CONSTRAINT [FK_Score_Course]

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Score_Student]') AND parent_object_id = OBJECT_ID(N'[dbo].[Score]'))

ALTER TABLE [dbo].[Score]  WITH CHECK ADD  CONSTRAINT [FK_Score_Student] FOREIGN KEY([studentNo])

REFERENCES [dbo].[Student] ([studentNo])

GO

ALTER TABLE [dbo].[Score] CHECK CONSTRAINT [FK_Score_Student]

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Score_Term]') AND parent_object_id = OBJECT_ID(N'[dbo].[Score]'))

ALTER TABLE [dbo].[Score]  WITH CHECK ADD  CONSTRAINT [FK_Score_Term] FOREIGN KEY([termNo])

REFERENCES [dbo].[Term] ([termNo])

GO

ALTER TABLE [dbo].[Score] CHECK CONSTRAINT [FK_Score_Term]

GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Student_Class]') AND parent_object_id = OBJECT_ID(N'[dbo].[Student]'))

ALTER TABLE [dbo].[Student]  WITH CHECK ADD  CONSTRAINT [FK_Student_Class] FOREIGN KEY([classNo])

REFERENCES [dbo].[Class] ([classNo])

GO

ALTER TABLE [dbo].[Student] CHECK CONSTRAINT [FK_Student_Class]

3.設計數據庫關系圖

創建原始數據庫——創建數據、創建表

實戰經驗:建立主鍵與外鍵關系時,兩者數據類型必須一致。

作者提供原始數據,請點擊鏈接下載:http://down.51cto.com/data/2456174

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

南召县| 南皮县| 西乡县| 镇坪县| 兰考县| 隆回县| 雷波县| 来宾市| 延安市| 屯门区| 庐江县| 尼玛县| 香河县| 余江县| 宁远县| 米泉市| 腾冲县| 金坛市| 南召县| 积石山| 神木县| 吉木乃县| 寿光市| 温州市| 北京市| 青冈县| 华宁县| 昌江| 乌兰县| 陆丰市| 珠海市| 双城市| 辛集市| 安乡县| 南皮县| 吉首市| 鲜城| 大冶市| 乌苏市| 新巴尔虎左旗| 长顺县|