- Use master
- go
- If Exists (Select * From sysdatabases Where name = 'bbs') --检查是否以存在bbsDB数据库
- Drop Database bbs
- go
- /*---- 创建文件夹 ----*/
- --sql 2005如何使用被禁止的"xp_cmdshell"
- USE master
- EXEC sp_configure 'show advanced options', 1
- RECONFIGURE WITH OVERRIDE
- EXEC sp_configure 'xp_cmdshell', 1
- RECONFIGURE WITH OVERRIDE
- EXEC sp_configure 'show advanced options', 0
- go
- Exec xp_cmdshell 'mkdir D:/bbsDB' --调用DOS命令创建文件夹
- go
- /*------ 建库 ------*/
- Create Database bbs
- on
- (
- /*-------- 数据文件具体描述 ----------*/
- Name = 'bbs_data', --主数据文件的逻辑名称
- FileName = 'D:/bbsDB/bbs_data.mdf', --数据文件的物理名称
- Size = 5Mb, -- 主数据文件的初始大小
- FileGrowth = 20% --主数据文件增长率
- )
- log on
- (
- /* ------ 日志文件的具体描述,各参数含义同上 ------ */
- Name = 'bbs_log',
- FileName = 'd:/bbsDB/bbs_log.ldf',
- Size = 3Mb,
- FileGrowth = 10%
- )
- go
- -----------------------------------------------
- /*--- 创建表 ---*/
- Use bbs
- go
- /* --- 检查是否存在表TBL_USER ---*/
- If Exists (Select * From Sysobjects where name = 'TBL_USER')
- Drop Table TBL_USER
- Create Table TBL_USER
- (
- uId int primary key identity(1,1), --主键,标识列
- uName varchar(20) Unique(uName) not null,
- uPass varchar(20) not null,
- head varchar(100) not null,
- regTime dateTime not null,
- gender smallint not null
- )
- go