BBS源代码Word格式.docx
《BBS源代码Word格式.docx》由会员分享,可在线阅读,更多相关《BBS源代码Word格式.docx(16页珍藏版)》请在冰豆网上搜索。
(
name=BBS_data,--Â
ß
Ã
û
filename='
d:
\BBS_data.mdf'
--Î
ï
À
Î
Ä
þ
size=20MB,--³
õ
´
ó
Ð
¡
filegrowth=10%,--Î
ö
³
¤
Â
maxsize=200MB--³
logon
name=bbs_log,--Â
\bbs_data.ldf'
size=10mb,--³
filegrowth=10%,--Î
maxsize=100MB--×
î
ç
useBBS
ifexists(select*fromsysobjectswherename='
BBSUsers'
droptableBBSUsers
createtableBBSUsers
Uidintconstraintpk_Uidprimarykey,--Ó
Ã
»
§
à
º
Å
Unamechar(8)notnull,--Ó
Õ
UPasswordchar(16)constraintdf_UPassworddefault'
888888'
--Ó
Ü
UEmailchar(20)notnullconstraintck_Uemailcheck(Uemaillike'
%@%.%'
),--Ó
EMAIL
UBirthdaydatetimenotnull,--Ó
É
ú
Usexintconstraintdf_Usexdefault'
1'
--Ó
ð
UClassintconstraintdf_UClassdefault'
µ
¶
UStatementvarchar(150)notnull,--Ó
Ë
÷
URegDatedatetimenotnulldefaultgetdate(),--Ó
×
¢
á
ä
UStatetinyintconstraintdf_UStatedefault'
UPointintconstraintdf_UPointdefault'
20'
--Ó
·
Ö
constraintck_UPasswordcheck(UPasswordlike'
______'
BBSTopic'
droptableBBSTopic
createtableBBSTopic
tidintconstraintpk_tidprimarykey,--Ö
ù
tsidintnotnull,--Ö
°
é
tuidintnotnull,--Ö
treplycountintnotnull,--Ö
Ø
¸
temotionchar(10)notnull,--Ö
Ç
TTopicvarchar(16)notnullCONSTRAINTck_ttcheck(TTopicnotlike'
%'
'
),--Ö
ê
TContentstextnotnull,--Ö
TTimedatetimenotnulldefaultgetdate(),--·
TClickCountintnotnull,--µ
ã
TLastClickTdatetimenotnull,
CONSTRAINT[CK_TLC]CHECK([TLastClickT]>
=TTime)--Ö
BBSReply'
droptableBBSReply
createtableBBSReply
RIDintconstraintpk_RIDprimarykey,--»
RTIDint,--»
RSIDint,--»
RUIDint,--»
REmotionchar(10),--»
RTopicvarchar(20),--»
RContentstext,--»
RTimedatetimedefaultgetdate(),--»
RClickCountint,--»
BBSSection'
droptableBBSSection
createtableBBSSection
SIDintconstraintpk_SIDprimarykey,--°
SNamechar(10),--°
Æ
SMasterIDint,--°
SStatementvarchar(80),--°
SClickCountintconstraintdf_SClickCountdefault'
0'
--°
STopicCountintconstraintdf_STopicCountdefault'
--°
--Á
ª
Ï
altertableBBSTopic
addconstraintfk1_BBSTopic_BBSUsersforeignkey(tuid)referencesBBSUsers(Uid)--Ò
Ò
altertableBBSReply
addconstraintfk1_BBSReply_BBSTopicforeignkey(RTID)referencesBBSTopic(TID)--Ò
¹
¦
addconstraintfk1_BBSReply_BBSUsersforeignkey(RUID)referencesBBSUsers(UID)--Ò
addconstraintfk1_BBSTopic_BBSSectionforeignkey(tsid)referencesBBSSection(Sid)--Ò
ü
addconstraintfk1_BBSReply_BBSSectionforeignkey(RSID)referencesBBSSection(Sid)--Ò
altertableBBSSection
addconstraintfk1_BBSSection_BBSUsersforeignkey(SMasterID)referencesBBSUsers(Uid)--Ò
insert
intoBBSUsers(uid,uname,upassword,uemail,UBirthday,USex,UClass,UStatement,URegDate,UState,UPoint)
values('
1001'
'
Á
'
123456'
1990@'
1990-12-12'
ANGEL'
2010-5-7'
2'
1002'
Í
654321'
1965@'
1980-7-1'
2011-4-7'
4'
1003'
158664'
conao@'
1997-1-03'
2009-5-7'
3'
1004'
Ù
175175'
death@'
1992-1-4'
2008-5-4'
1005'
®
198755'
sgg@'
1994-1-4'
2000-12-12'
100'
1006'
192445'
dsfg@'
1994-12-14'
fdfs'
97'
--Section
intoBBSSection(SID,SName,SMasterID,SStatement,SClickCount,STopicCount)
01'
5'
02'
--topic
intoBBSTopic(tid,TSID,TUID,TReplyCount,TEmotion,TTopic,TContents,TTime,TClickCount,TLastClickT)
2001'
.....'
DEVILMAYCRY'
2011-1-10'
2011-6-24'
2002'
~~'
2011-4-10'
2011-6-28'
2003'
1~~'
2011-6-27'
2004'
2~~'
2011-6-26'
2005'
3~~'
2011'
2011-1-11'
6'
2011-6-29'
2012'
Û
DNº
7'
2011-6-23'
2013'
Ñ
2011-2-11'
8'
2014'
ò
~'
2011-1-21'
2011-6-11'
--reply
intoBBSReply(RID,RTID,RSID,RUID,REmotion,RTopic,RContents,RTime,RClickCount)
9001'
9002'
9003'
9004'
select*fromBBSUsers
select*fromBBSSection
select*fromBBSTopic
select*fromBBSReply
¯
selectunameasÐ
Uemailasµ
UregDateas×
frombbsUsers
where--datediff(yyyy,uregdate,getdate())>
2
dateadd(yyyy,2,uregdate)<
getdate()
--Î
Þ
updatebbsUserssetUBirthday='
whereuid=1002
ñ
selectunameÐ
uBirthday³
frombbsUsers
where--datepart(mm,ubirthday)=datepart(mm,getdate())and
--datepart(dd,ubirthday)=datepart(dd,getdate())
day(getdate())=day(ubirthday)andmonth(getdate())=month(ubirthday)
--°
(×
2Ä
)µ
4Ã
--Ð
/Ð
/»
/×
UPointas»
orderbyUPointdesc
updatebbsUserssetUState='
whereuid=1004
select*
whereUState=1orUState=3
selectRTopicas»
RTimeas»
frombbsreply
orderbyRTimedesc
BBSTopic±
5Ã
selecttop5TTopicasÖ
TClickCountasÖ
frombbstopic
orderbyTClickCountdesc
--Ò
Ò
updatebbstopicsetttime='
wheretid='
updatebbstopicsetTLastClickT='
2011-6-30'
--¸
7Ì
Ö
2Ã
--Ï
selecttop2tuidasÓ
ID,count(*)as·
wheredatediff(dd,ttime,getdate())<
=7
groupbytuid
--bbsTopic
--Max()¡
Min()¡
ID·
selecttuidasÓ
ID,max(TReplyCount)×
min(TReplyCount)as×
--T-SQLÅ
begin
--T-SQL±
declare@minPointint--¶
--²
²
@minPoint
select@minPoint=min(upoint)frombbsUsers
wheredateadd(yyyy,2,uregdate)<
--