-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHOTEL_DB.sql
245 lines (244 loc) · 16.5 KB
/
HOTEL_DB.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
USE [master]
GO
/****** Object: Database [HotelDB] Script Date: 2020/12/31 20:20:06 ******/
CREATE DATABASE [HotelDB]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'HotelDB', FILENAME = N'D:\sql\MSSQL15.MSSQLSERVER\MSSQL\DATA\HotelDB.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N'HotelDB_log', FILENAME = N'D:\sql\MSSQL15.MSSQLSERVER\MSSQL\DATA\HotelDB_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
WITH CATALOG_COLLATION = DATABASE_DEFAULT
GO
ALTER DATABASE [HotelDB] SET COMPATIBILITY_LEVEL = 150
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [HotelDB].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [HotelDB] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [HotelDB] SET ANSI_NULLS OFF
GO
ALTER DATABASE [HotelDB] SET ANSI_PADDING OFF
GO
ALTER DATABASE [HotelDB] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [HotelDB] SET ARITHABORT OFF
GO
ALTER DATABASE [HotelDB] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [HotelDB] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [HotelDB] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [HotelDB] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [HotelDB] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [HotelDB] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [HotelDB] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [HotelDB] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [HotelDB] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [HotelDB] SET DISABLE_BROKER
GO
ALTER DATABASE [HotelDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [HotelDB] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [HotelDB] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [HotelDB] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [HotelDB] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [HotelDB] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [HotelDB] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [HotelDB] SET RECOVERY FULL
GO
ALTER DATABASE [HotelDB] SET MULTI_USER
GO
ALTER DATABASE [HotelDB] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [HotelDB] SET DB_CHAINING OFF
GO
ALTER DATABASE [HotelDB] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [HotelDB] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
ALTER DATABASE [HotelDB] SET DELAYED_DURABILITY = DISABLED
GO
EXEC sys.sp_db_vardecimal_storage_format N'HotelDB', N'ON'
GO
ALTER DATABASE [HotelDB] SET QUERY_STORE = OFF
GO
USE [HotelDB]
GO
/****** Object: Table [dbo].[房间信息] Script Date: 2020/12/31 20:20:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[房间信息](
[房间号] [varchar](6) NOT NULL,
[房间类型] [varchar](10) NOT NULL,
[价格] [varchar](10) NOT NULL,
[床型] [varchar](50) NOT NULL,
[窗型] [varchar](50) NOT NULL,
[状态] [varchar](10) NOT NULL,
CONSTRAINT [PK_房间信息] PRIMARY KEY CLUSTERED
(
[房间号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[经理信息] Script Date: 2020/12/31 20:20:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[经理信息](
[经理号] [varchar](4) NOT NULL,
[经理姓名] [varchar](10) NOT NULL,
CONSTRAINT [PK_经理信息] PRIMARY KEY CLUSTERED
(
[经理号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[客户] Script Date: 2020/12/31 20:20:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[客户](
[客户编号] [int] NOT NULL,
[客户身份证号] [varchar](20) NOT NULL,
[客户姓名] [varchar](10) NOT NULL,
[客户手机号] [varchar](11) NOT NULL,
[账户余额] [float] NOT NULL,
[客户类别] [varchar](10) NOT NULL,
[享受折扣] [float] NOT NULL,
[状态] [varchar](10) NOT NULL,
CONSTRAINT [PK_客户] PRIMARY KEY CLUSTERED
(
[客户编号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[历史订单] Script Date: 2020/12/31 20:20:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[历史订单](
[订单号] [int] NOT NULL,
[客户编号] [int] NOT NULL,
[入住房间号] [varchar](3) NOT NULL,
[入住时间] [date] NOT NULL,
[实际退房时间] [date] NOT NULL,
[超时缴费] [float] NOT NULL,
[总消费] [float] NOT NULL,
CONSTRAINT [PK_历史订单] PRIMARY KEY CLUSTERED
(
[订单号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[入住信息] Script Date: 2020/12/31 20:20:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[入住信息](
[订单号] [int] NOT NULL,
[客户编号] [int] NOT NULL,
[入住房间号] [varchar](3) NOT NULL,
[入住时间] [date] NOT NULL,
[计划天数] [int] NOT NULL,
[预计退房时间] [date] NOT NULL,
[订单状态] [varchar](10) NOT NULL,
CONSTRAINT [PK_入住信息] PRIMARY KEY CLUSTERED
(
[订单号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[员工信息] Script Date: 2020/12/31 20:20:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[员工信息](
[员工号] [varchar](4) NOT NULL,
[员工姓名] [varchar](10) NOT NULL,
[员工性别] [varchar](10) NOT NULL,
[员工身份证号] [varchar](18) NOT NULL,
[员工职位] [varchar](10) NOT NULL,
[员工工资] [varchar](10) NOT NULL,
[员工密码] [varchar](10) NOT NULL,
[员工手机号] [varchar](11) NOT NULL,
CONSTRAINT [PK_员工信息] PRIMARY KEY CLUSTERED
(
[员工号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [index_room_id] Script Date: 2020/12/31 20:20:07 ******/
CREATE NONCLUSTERED INDEX [index_room_id] ON [dbo].[房间信息]
(
[房间号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
/****** Object: Index [index_wker_id] Script Date: 2020/12/31 20:20:07 ******/
CREATE NONCLUSTERED INDEX [index_wker_id] ON [dbo].[客户]
(
[客户编号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
/****** Object: Index [IX_客户] Script Date: 2020/12/31 20:20:07 ******/
CREATE NONCLUSTERED INDEX [IX_客户] ON [dbo].[客户]
(
[客户编号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [index_yg_id] Script Date: 2020/12/31 20:20:07 ******/
CREATE NONCLUSTERED INDEX [index_yg_id] ON [dbo].[员工信息]
(
[员工号] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
ALTER TABLE [dbo].[客户] WITH CHECK ADD CONSTRAINT [FK_客户_客户] FOREIGN KEY([客户编号])
REFERENCES [dbo].[客户] ([客户编号])
GO
ALTER TABLE [dbo].[客户] CHECK CONSTRAINT [FK_客户_客户]
GO
/****** Object: StoredProcedure [dbo].[proc_PhoneNum] Script Date: 2020/12/31 20:20:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[proc_PhoneNum]
@randCardID varchar(19) OUTPUT, --输出参数
@firstNo varchar(4)='156' --输入参数,有默认值
AS
DECLARE @r numeric(15,8) --15位数,保留8位小数
DECLARE @tempStr char(10)
select @r=RAND((DATEPART(mm,GETDATE())*100000)+(DATEPART(ss,GETDATE())*1000)+DATEPART(ms,GETDATE()))
SET @tempStr=@r
SET @randCardID=@firstNo+SUBSTRING(@tempStr,3,4)+SUBSTRING(@tempStr,7,4)
GO
USE [master]
GO
ALTER DATABASE [HotelDB] SET READ_WRITE
GO