1. 程式人生 > >SQL server 練習2的資料庫 sql檔案

SQL server 練習2的資料庫 sql檔案

CREATE DATABASE [stuManage] CONTAINMENT = NONE ON PRIMARY ( NAME = N'stuManage2', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\stuManage2.mdf' , SIZE = 4096KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'stuManage2_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\stuManage2_log.ldf'
, SIZE = 5184KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) GO ALTER DATABASE [stuManage] SET COMPATIBILITY_LEVEL = 90 GO IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')) begin EXEC [stuManage].[dbo].[sp_fulltext_database] @action = 'disable' end GO ALTER DATABASE [stuManage] SET ANSI_NULL_DEFAULT OFF GO
ALTER DATABASE [stuManage] SET ANSI_NULLS OFF GO ALTER DATABASE [stuManage] SET ANSI_PADDING OFF GO ALTER DATABASE [stuManage] SET ANSI_WARNINGS OFF GO ALTER DATABASE [stuManage] SET ARITHABORT OFF GO ALTER DATABASE [stuManage] SET AUTO_CLOSE OFF GO ALTER DATABASE [stuManage] SET AUTO_CREATE_STATISTICS ON
GO ALTER DATABASE [stuManage] SET AUTO_SHRINK OFF GO ALTER DATABASE [stuManage] SET AUTO_UPDATE_STATISTICS ON GO ALTER DATABASE [stuManage] SET CURSOR_CLOSE_ON_COMMIT OFF GO ALTER DATABASE [stuManage] SET CURSOR_DEFAULT GLOBAL GO ALTER DATABASE [stuManage] SET CONCAT_NULL_YIELDS_NULL OFF GO ALTER DATABASE [stuManage] SET NUMERIC_ROUNDABORT OFF GO ALTER DATABASE [stuManage] SET QUOTED_IDENTIFIER OFF GO ALTER DATABASE [stuManage] SET RECURSIVE_TRIGGERS OFF GO ALTER DATABASE [stuManage] SET DISABLE_BROKER GO ALTER DATABASE [stuManage] SET AUTO_UPDATE_STATISTICS_ASYNC OFF GO ALTER DATABASE [stuManage] SET DATE_CORRELATION_OPTIMIZATION OFF GO ALTER DATABASE [stuManage] SET TRUSTWORTHY OFF GO ALTER DATABASE [stuManage] SET ALLOW_SNAPSHOT_ISOLATION OFF GO ALTER DATABASE [stuManage] SET PARAMETERIZATION SIMPLE GO ALTER DATABASE [stuManage] SET READ_COMMITTED_SNAPSHOT OFF GO ALTER DATABASE [stuManage] SET HONOR_BROKER_PRIORITY OFF GO ALTER DATABASE [stuManage] SET RECOVERY FULL GO ALTER DATABASE [stuManage] SET MULTI_USER GO ALTER DATABASE [stuManage] SET PAGE_VERIFY CHECKSUM GO ALTER DATABASE [stuManage] SET DB_CHAINING OFF GO ALTER DATABASE [stuManage] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) GO ALTER DATABASE [stuManage] SET TARGET_RECOVERY_TIME = 0 SECONDS GO EXEC sys.sp_db_vardecimal_storage_format N'stuManage', N'ON' GO USE [stuManage] GO /****** Object: Table [dbo].[course] Script Date: 2018/4/15 23:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[course]( [cNO] [char](6) NOT NULL, [cName] [char](40) NOT NULL, [cpNO] [char](6) NULL, CONSTRAINT [PK_course] 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].[course_class] Script Date: 2018/4/15 23:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[course_class]( [ccNO] [char](10) NOT NULL, [cNO] [char](6) NULL, [Term] [varchar](12) NULL, [tNO] [char](6) NULL, [CourseType] [varchar](10) NULL, [ExamType] [varchar](10) NULL, [Credit] [smallint] NULL, [Room] [varchar](20) NULL, [WeekTime] [varchar](20) NULL, [validity] [bit] NULL, CONSTRAINT [PK_course_class] PRIMARY KEY CLUSTERED ( [ccNO] 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].[department] Script Date: 2018/4/15 23:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[department]( [dNO] [char](6) NOT NULL, [dName] [varchar](20) NULL, [dTel] [varchar](11) NULL, CONSTRAINT [PK_department] PRIMARY KEY CLUSTERED ( [dNO] 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].[major] Script Date: 2018/4/15 23:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[major]( [mNO] [char](6) NOT NULL, [mName] [varchar](40) NULL, [mSubject] [varchar](40) NULL, [dNO] [char](6) NULL, CONSTRAINT [PK_major] PRIMARY KEY CLUSTERED ( [mNO] 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].[student] Script Date: 2018/4/15 23:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[student]( [sNO] [varchar](10) NOT NULL, [sName] [varchar](20) NOT NULL, [mNO] [char](6) NOT NULL, [sSex] [char](4) NULL, [sBirth] [smalldatetime] NULL, [sNative] [varchar](20) NULL, [sHeight] [int] NULL, [sWeight] [int] NULL, [sEntime] [smalldatetime] NULL, CONSTRAINT [PK_student] 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].[student_course] Script Date: 2018/4/15 23:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[student_course]( [sNO] [varchar](10) NOT NULL, [ccNO] [char](10) NOT NULL, [NormalMark] [tinyint] NULL, [ExamMark] [tinyint] NULL, [Mark] [tinyint] NULL, CONSTRAINT [PK_student_course] PRIMARY KEY CLUSTERED ( [sNO] ASC, [ccNO] 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].[teacher] Script Date: 2018/4/15 23:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[teacher]( [tNO] [char](6) NOT NULL, [tName] [varchar](20) NULL, [tSex] [char](4) NULL, [tBirth] [datetime] NULL, [tRank] [varchar](20) NULL, [tDegree] [char](6) NULL, [dNo] [char](6) NULL, CONSTRAINT [PK_teacher] PRIMARY KEY CLUSTERED ( [tNO] 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: View [dbo].[mark_rank_view] Script Date: 2018/4/15 23:06:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create view [dbo].[mark_rank_view] as select top 10 student.sName,mark,'金融學' as '科目' from student,student_course,course_class,course where student.sNO = student_course.sNO and student_course.ccNO = course_class.ccNo and course_class.cNo = course.cNo and course.cName='金融學' order by mark desc ;
GO