USE [master]
GO
/****** Object: Database [MSPetShop4Orders] Script Date: 2020/4/13 21:31:01 ******/
CREATE DATABASE [MSPetShop4Orders]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'MSPetShop4Orders', FILENAME = N'C:Program FilesMicrosoft SQL ServerMSSQL12.MSSQLSERVERMSSQLDATAMSPetShop4Orders.mdf' , SIZE = 4288KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'MSPetShop4Orders_log', FILENAME = N'C:Program FilesMicrosoft SQL ServerMSSQL12.MSSQLSERVERMSSQLDATAMSPetShop4Orders_log.ldf' , SIZE = 1072KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [MSPetShop4Orders] SET COMPATIBILITY_LEVEL = 120
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [MSPetShop4Orders].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [MSPetShop4Orders] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET ANSI_NULLS OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET ANSI_PADDING OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET ARITHABORT OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [MSPetShop4Orders] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [MSPetShop4Orders] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET ENABLE_BROKER
GO
ALTER DATABASE [MSPetShop4Orders] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [MSPetShop4Orders] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET RECOVERY FULL
GO
ALTER DATABASE [MSPetShop4Orders] SET MULTI_USER
GO
ALTER DATABASE [MSPetShop4Orders] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [MSPetShop4Orders] SET DB_CHAINING OFF
GO
ALTER DATABASE [MSPetShop4Orders] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [MSPetShop4Orders] SET TARGET_RECOVERY_TIME = 0 SECONDS
GO
ALTER DATABASE [MSPetShop4Orders] SET DELAYED_DURABILITY = DISABLED
GO
EXEC sys.sp_db_vardecimal_storage_format N'MSPetShop4Orders', N'ON'
GO
USE [MSPetShop4Orders]
GO
/****** Object: User [mspetshop] Script Date: 2020/4/13 21:31:01 ******/
CREATE USER [mspetshop] FOR LOGIN [mspetshop] WITH DEFAULT_SCHEMA=[mspetshop]
GO
ALTER ROLE [db_owner] ADD MEMBER [mspetshop]
GO
/****** Object: Schema [mspetshop] Script Date: 2020/4/13 21:31:01 ******/
CREATE SCHEMA [mspetshop]
GO
/****** Object: Table [dbo].[LineItem] Script Date: 2020/4/13 21:31:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LineItem](
[OrderId] [int] NOT NULL,
[LineNum] [int] NOT NULL,
[ItemId] [varchar](10) NOT NULL,
[Quantity] [int] NOT NULL,
[UnitPrice] [decimal](10, 2) NOT NULL,
CONSTRAINT [PkLineItem] PRIMARY KEY CLUSTERED
(
[OrderId] ASC,
[LineNum] 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].[Orders] Script Date: 2020/4/13 21:31:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Orders](
[OrderId] [int] IDENTITY(1,1) NOT NULL,
[UserId] [varchar](20) NOT NULL,
[OrderDate] [datetime] NOT NULL,
[ShipAddr1] [varchar](80) NOT NULL,
[ShipAddr2] [varchar](80) NULL,
[ShipCity] [varchar](80) NOT NULL,
[ShipState] [varchar](80) NOT NULL,
[ShipZip] [varchar](20) NOT NULL,
[ShipCountry] [varchar](20) NOT NULL,
[BillAddr1] [varchar](80) NOT NULL,
[BillAddr2] [varchar](80) NULL,
[BillCity] [varchar](80) NOT NULL,
[BillState] [varchar](80) NOT NULL,
[BillZip] [varchar](20) NOT NULL,
[BillCountry] [varchar](20) NOT NULL,
[Courier] [varchar](80) NOT NULL,
[TotalPrice] [decimal](10, 2) NOT NULL,
[BillToFirstName] [varchar](80) NOT NULL,
[BillToLastName] [varchar](80) NOT NULL,
[ShipToFirstName] [varchar](80) NOT NULL,
[ShipToLastName] [varchar](80) NOT NULL,
[AuthorizationNumber] [int] NOT NULL,
[Locale] [varchar](20) NOT NULL,
PRIMARY KEY CLUSTERED
(
[OrderId] 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].[OrderStatus] Script Date: 2020/4/13 21:31:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[OrderStatus](
[OrderId] [int] NOT NULL,
[LineNum] [int] NOT NULL,
[Timestamp] [datetime] NOT NULL,
[Status] [varchar](2) NOT NULL,
CONSTRAINT [PkOrderStatus] PRIMARY KEY CLUSTERED
(
[OrderId] ASC,
[LineNum] 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
ALTER TABLE [dbo].[LineItem] WITH CHECK ADD FOREIGN KEY([OrderId])
REFERENCES [dbo].[Orders] ([OrderId])
GO
ALTER TABLE [dbo].[OrderStatus] WITH CHECK ADD FOREIGN KEY([OrderId])
REFERENCES [dbo].[Orders] ([OrderId])
GO
USE [master]
GO
ALTER DATABASE [MSPetShop4Orders] SET READ_WRITE
GO