首页 新闻 会员 周边

创建存贮过程问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2013-01-09 10:04

1.实现对“新增版块”,将一个版块的数据加到数据库相应的表里。

调用该存贮过程,新增一个版块

 

2.根据版块编号,查询该版块的所有帖子,要求:发帖人使用发帖人的昵称。

调用该存贮过程,显示版块编号为2的帖子信息。

use master 
go
if DB_ID(N'bbsDB')is not null
   drop database bbsDB
go
create database bbsDB
on primary
(
name=bbsDB_dat,
filename='f:\bbsDB.mdf',
size=10mb,
maxsize=100mb,
filegrowth=5mb
)
log on
(
name=bbsDB_log,
filename='f:\bbsDBLog.ldf',
size=10mb,
maxsize=unlimited,
filegrowth=5mb
)
go

--convert(varchar(10),getdate(),120))

use bbsDB 
go
create table Users
(
UID int identity(1,1),
UName varchar(50) not null,
UPassword varchar(50) not null,
UEmail varchar(50),
UBirthday datetime,
USex varchar(2),
UClass char(5)not null,
UNote varchar(50),
URegDate datetime not null,
UState char(5)not null,
UPoint int not null
)
go

alter table users
add constraint pkey_users primary key(UID)
go

insert into Users (UName ,UPassword ,UEmail ,UBirthday ,USex ,UClass ,UNote ,URegDate ,UState ,UPoint)
values('冷溪水','lxs','HYXS@HotMail.com','1978-7-19','','5','快。。','2005-8-19','1',2000)

create table Section
(
SID int not null,
SName varchar(50)not null,
SMasterID int not null,
SStatement varchar(250)not null,
SClickCount int not null,
STopicCount int not null
)
go

drop table section

use bbsDB 
go
insert into Section(SID ,SName ,SMasterID ,SStatement ,SClickCount ,STopicCount)
values(1,'逍遥体苑',3,'足球,篮球,羽毛球,自行车,游泳,钓鱼...等体育竞技,召集,评论区,相得益彰的体育活动,让我们在户外走得更宽更远更广。',50,0)

alter table section
add constraint pkey_section primary key(SID)
go

create table Topic
(
TID int not null,
TSID int not null,
TUID int not null,
TReplyCount int not null,
TEmotion varchar(10),
TTopic varchar(50)not null,
TContents varchar(50)not null,
TTime datetime,
TClickCount int not null,
TFlag char(5),
TLastClick datetime
)
go

insert into Topic (TID ,TSID ,TUID ,TReplyCount ,TEmotion ,TTopic ,TContents ,TTime ,TClickCount ,TFlag ,TLastClick )
values(1,2,2,1,'1','11月4日登黄杨山 ','本周六(11月4日)重阳…','2005-1-1',2343,'1','2005-8-1 17:31:21')

alter table Topic
add constraint pkey_topic primary key(TID)
go

create table Reply
(
RID int not null,
RTID int not null,
RSID int not null,
RUID int not null,
REmotion varchar(50),
RTopic varchar(50)not null,
RContents varchar(50)not null,
RTime datetime,
RClickCount int not null
)
go

insert into Reply (RID ,RTID ,RSID ,RUID ,REmotion ,RTopic ,RContents ,RTime ,RClickCount)
values(1,1,1,4,'2','好活动,报名+1. ','如题','2005-5-1',5)

alter table Reply
add constraint pkey_reply primary key(RID)
go


上面的代码是我创建bbs数据库的代码

Allen小飞的主页 Allen小飞 | 初学一级 | 园豆:62
提问于:2013-01-08 16:28
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册