急求SQL 数据库实例!~
急求SQL数据库实例!~书上讲得实在太空了...老师也没有要求怎么弄..只是给了个任务书..有的人麻烦发到我邮箱xstdf@163.com谢谢!~酒店管理,图书馆借还系统......
急求SQL 数据库实例!~
书上讲得实在太空了...
老师也没有要求怎么弄..
只是给了个任务书..
有的人麻烦发到我邮箱
xstdf@163.com
谢谢!~
酒店管理,图书馆借还系统... 展开
书上讲得实在太空了...
老师也没有要求怎么弄..
只是给了个任务书..
有的人麻烦发到我邮箱
xstdf@163.com
谢谢!~
酒店管理,图书馆借还系统... 展开
2个回答
展开全部
直接给你代码,你在查询语句里执行一次就可以了
use master
go
----查询是否存在bbsDB数据库,有的话删除----
if exists (select * from sysdatabases where name='bbsDB')
drop database bbsDB
go
----创建bbsDB数据库----
create database bbsDB
on primary
(
name='bbsDB_data',
filename='D:\BBS数据库zxy\bbsDB_data.mdf',
size=10MB,
filegrowth=20%
)
log on
(
name='bbsDB_log',
filename='D:\BBS数据库zxy\bbsDB_log.ldf',
size=3MB,
maxsize=20MB,
filegrowth=10%
)
go
use bbsDB
go
----创建表----
--是否已经存在bbsUsers表(用户表),存在就删除
if exists (select * from sysobjects where name='bbsUsers')
drop table bbsUsers
--创建bbsUsers表
create table bbsUsers
(
UID int identity(1,1) not null,
Uname varchar(15) not null,
Upassword varchar(10),
Ubirthday datetime not null,
Uemail varchar(20),
Usex bit not null,
Uclass int not null,
Uremark varchar(20),
UregDate datetime not null,
Ustate int ,
Upoint int
)
go
--为bbsUsers表添加约束
alter table bbsUsers
add constraint PK_UID
primary key (UID)
alter table bbsUsers
add constraint DF_Upassword
default(888888)for Upassword
alter table bbsUsers
add constraint CK_Upassword
check (len(Upassword)>=6)
alter table bbsUsers
add constraint CK_Uemail
check(Uemail like '%@%')
alter table bbsUsers
add constraint DF_Usex
default (1) for Usex
alter table bbsUsers
add constraint DF_Uclass
default (1) for Uclass
alter table bbsUsers
add constraint DF_UregDate
default(getdate())for UregDate
alter table bbsUsers
add constraint DF_Ustate
default (0)for Ustate
alter table bbsUsers
add constraint DF_Upoint
default (20)for Upoint
go
use master
go
----查询是否存在bbsDB数据库,有的话删除----
if exists (select * from sysdatabases where name='bbsDB')
drop database bbsDB
go
----创建bbsDB数据库----
create database bbsDB
on primary
(
name='bbsDB_data',
filename='D:\BBS数据库zxy\bbsDB_data.mdf',
size=10MB,
filegrowth=20%
)
log on
(
name='bbsDB_log',
filename='D:\BBS数据库zxy\bbsDB_log.ldf',
size=3MB,
maxsize=20MB,
filegrowth=10%
)
go
use bbsDB
go
----创建表----
--是否已经存在bbsUsers表(用户表),存在就删除
if exists (select * from sysobjects where name='bbsUsers')
drop table bbsUsers
--创建bbsUsers表
create table bbsUsers
(
UID int identity(1,1) not null,
Uname varchar(15) not null,
Upassword varchar(10),
Ubirthday datetime not null,
Uemail varchar(20),
Usex bit not null,
Uclass int not null,
Uremark varchar(20),
UregDate datetime not null,
Ustate int ,
Upoint int
)
go
--为bbsUsers表添加约束
alter table bbsUsers
add constraint PK_UID
primary key (UID)
alter table bbsUsers
add constraint DF_Upassword
default(888888)for Upassword
alter table bbsUsers
add constraint CK_Upassword
check (len(Upassword)>=6)
alter table bbsUsers
add constraint CK_Uemail
check(Uemail like '%@%')
alter table bbsUsers
add constraint DF_Usex
default (1) for Usex
alter table bbsUsers
add constraint DF_Uclass
default (1) for Uclass
alter table bbsUsers
add constraint DF_UregDate
default(getdate())for UregDate
alter table bbsUsers
add constraint DF_Ustate
default (0)for Ustate
alter table bbsUsers
add constraint DF_Upoint
default (20)for Upoint
go
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询