首页 技术 正文
技术 2022年11月11日
0 收藏 976 点赞 2,883 浏览 3427 个字
use master
go
if exists(select * from sysdatabases where name='learning')
drop database learning
go
CREATE DATABASE learning
ON
( NAME='learning_data', --主数据文件的逻辑名称
FILENAME='E:\SQLlearning\learning.mdf', -- 主数据文件的物理名称
SIZE=10MB, --主数据文件的初始大小
MAXSIZE=50MB, -- 主数据文件增长的最大值
FILEGROWTH=% --主数据文件的增长率
)
--/*--日志文件的具体描述,各参数含义同上--*/
LOG ON(
NAME='learning_log',
FILENAME='E:\SQLlearning\learning.ldf',
SIZE=5MB,
MAXSIZE=25MB,
FILEGROWTH=5MB)
GOUSE learning
GO
--在视图sysobjects中查找是否存在userInfo表格
if exists(select * from dbo.sysobjects where name='userInfo')
drop table userInfo
GO
--用户信息表格
create table userInfo
(
userId int not null, --自增长ID
userName varchar() not null, --用户姓名
password varchar() not null, --用户密码
email varchar() not null, --用户邮箱
userRole int, --用户角色(:普通会员,1管理员)
registerDate varchar() --注册时间(默认当前时间)
)
--员工信息表格
if exists(select * from sysobjects where name='employInfo')
drop table employInfo
GO
create table employInfo
(
employId int not null, --自增长ID
employNumber varchar() not null, --员工编号
employPassword varchar() not null, --员工密码(默认6个8)
employRealName varchar() not null, --员工真实姓名
employPhoneNum varchar() not null --员工联系电话)--员工业绩表格
if exists(select * from dbo.sysobjects where name='employResult')
drop table employResult
GO
create table employResult
(
employResultId int not null, --自增长ID
employResultNum varchar() not null, --业绩编号
employNumber varchar() not null, --员工编号
houseNumber varchar() not null, --房屋编号
houseAmount float, --房屋售价/出租价
percentPaid float, --提成比例(%提成)
salesCompleted varchar(), --销售完成时间
)--房屋信息表格
if exists(select * from dbo.sysobjects where name='houseInfo')
drop table houseInfo
GO
create table houseInfo(
houseId int not null, --自增长ID
houseNumber varchar() not null, --房屋编号
userName varchar() not null, --房屋发布会员
employNumber varchar() not null, --房屋对应负责销售员工编号(唯一主键)
informationType int not null, --判断是发布出租/出售房屋类型(0代表发布出租信息,1代表发布出售信息)
houseOwnerName varchar() not null, --业主姓名
houseOwnerSex int not null, --业主性别(:代表男,:代表女)
houseOwnerPhoneNumber varchar(), --联系电话
houseArea varchar() not null, --房屋所在区域
houseSize int not null, --房屋面积
houseFloor int, --房屋出租/出售 楼层
houseTotalFloor int, --房屋总楼层数
HouseUnit varchar(), --房屋户型(一室一厅,二室一厅,)[数据存储值为:一室二厅]
BudgetPrice float, --预算价格
SpecificAddress varchar() not null, --房屋具体地址
houseFloorType int not null, --楼型,,[:代表高层,:代表多层,:平房,:其他]
otherRequirements varchar() --其他信息
) --房产资讯表格if exists(select * from dbo.sysobjects where name='houseNews')
drop table houseNews
GO
create table houseNews(
houseNewId int not null, --自增长ID
houseNewTheme varchar() not null, --咨询主题
houseNewContent text, --咨询内容
houseNewDate varchar() --发布日期
) --留言评论表
if exists(select * from dbo.sysobjects where name='Message')
drop table Message
GO
create table Message(
messageId int not null, --自增长ID
houseNumber varchar() not null, --房屋出租/出售编号(针对房屋编号留言)
messageContent varchar() not null, --留言内容
contact varchar(), --联系方式
messageDate varchar() not null --留言时间
) --添加约束
alter table userInfo add constraint pk_userId primary key(userId);
alter table userInfo add constraint DF_userRole default()for userRole;
alter table userInfo add constraint DF_registerDate default(CONVERT(varchar(),GETDATE(),)) for registerDate;alter table houseInfo add constraint pk_houseId primary key(houseId);alter table employInfo add constraint pk_employInfo primary key(employId);
alter table employInfo add constraint DF_employPassword default('')for employPassword;alter table employResult add constraint pk_employResult primary key(employResultId);alter table houseNews add constraint pk_houseNewId primary key(houseNewId);
alter table houseNews add constraint DF_houseNewDate default(CONVERT(varchar(),GETDATE(),)) for houseNewDate;alter table T_Message add constraint pk_messageId primary key(messageId);
alter table T_Message add constraint DF_messageDate default(CONVERT(varchar(),GETDATE(),))for messageDate;GO
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,990
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,504
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,348
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,133
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,765
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,843