创建BBS数据库并创建表

1.新建数据库BBS(主数据文件初始大小:3MB,最大大小不限,文件增量:1MB; 日志文件初始大小1MB, 最大大小10MB,文件增量20%)

2.在该数据库中创建版块表和帖子表

版块表(版块编号[主键,自增],版块名称)
帖子表(帖子编号[主键,自增],标题[非空],内容,发表时间,版块编号[外键])

create database BBS
on primary
(
	name='BBS',
	filename='D:\BBS.mdf',
	size=3MB,
	maxsize=unlimited,
	filegrowth=1MB
)
log on
(
	name='BBS_log',
	filename='D:\BBS_log.ldf',
	size=1MB,
	maxsize=10MB,
	filegrowth=20%
)

use BBS
create table section
(
	secId int primary key identity(1,1),
	secname varchar(20) not null
)
create table card
(
	caId int primary key identity(1,1),
	caname varchar(20) not null,
	content varchar(500)not null,
	publishtime datetime,
	secId int foreign key references section(secId)
)

猜你喜欢

转载自blog.csdn.net/weixin_48135624/article/details/115211450