-- 创建BBS数据库
create database bbsdb
on
(
name='bbsdb_data',
filename='e:\sql\bbsdb.mdf',
size=10,
maxsize=50,
filegrowth=5
)
log on
(
name='bbsdb_log',
filename='e:\sql\bbsdb.log',
size=5,
maxsize=25,
filegrowth=5)
use bbsdb
create table users
(
uid int not null,
uname nvarchar(32) not null,
upassword nvarchar(16) not null,
uemail nvarchar(32),
ubirthday datetime,
usex bit not null,
uclass int,
unote nvarchar(255),
uregdate datetime,
ustate int ,
upoint int
)
use bbsdb
create table section
(
sid int not null,
sname nvarchar(32) not null,
smasterid int,
sstatement nvarchar(255),
sclickcount int ,
stopiccount int
)
alter database bbsdb
table section
(sname nvarchar(32) unique not null)
check uemail [email=like]like'%@%'[/email]
-- 创建COLLEGE数据库
create database college
on
(
name='college_data',
filename='i:\college.mdf',
size = 10,
maxsize = 50,
filegrowth =5
)
log on
(
name= 'college_log',
filename='i:\college.log'
)
use college
create table student
(
学号 int unique not null,
姓名 nvarchar(32) not null,
性别 bit default '1',
身份证号 nvarchar(32) unique not null,
生日 datetime not null,
政治面貌 nvarchar(8) not null,
家庭住址 nvarchar(255) not null
)
use college
create table course
(
课程号 int unique not null,
课程名称 nvarchar(32) unique not null,
学时 int not null,
学分 int not null
)
use college
create table score
(
学号 int unique not null,
课程号 int not null,
成绩 int not null
)
insert into student
values
('0136103','傅洪平','1','232302192901227516','1989-01-22','团员','绥化')
insert into course
values
('2','VB','48','15')
insert into score
values
('0836109','1','88')
-- 查询语句
select *from dbo.student
--创建Adventerworks数据库
create database [adventureworks]
on
primary( name = 'adventureworks_data' ,
filename = 'e:\adventureworks_data.mdf'),
filegroup [orderhistorygroup]
( name = 'ordhist1', filename = 'f:\ordhist1.ndf'),
( name = 'ordhist2', filename = 'f:\ordhist2.ndf')
log on
(name = 'adventureworks_log', filename = 'f:\adventureworks_log,ldf')
use adventureworks
go
create schema sales
go
use adventureworks
create table sales.customerorders
(
orderid int not null,
orderdate datetime not null,
customerid int not null
)
use adventureworks
create table sales.ReturnedGoods
(
ReturnID int not NULL,
ProductID int not NULL,
CustomerID int not NULL,
ReturnDate datetime not NULL,
ReturnReason shortdescription NULL
)
use adventureworks
create table sales.Refunds
(
RefundID int not null,
ReturnID int not null,
Amount CashValue not null
)