SQL Server 相关create操作语句
创建数据库:
create database jylt
on (
name=jylt,
filename='e:\db\jylt.mdf',
size=4,
filegrowth=100%,
maxsize=1024
)
log on
(
name=jylt_log,
filename='e:\db\jylt_log.ldf',
size=4,
filegrowth=100%
)
go
1,增:insert into t_user values('wangpeng','19');s
2,删:delete from t_user where t_user.age<30
3,改:update t_user name='xiaohong' where name='dahong'
4,查:select name as '名字' age as '年龄' from t_user where name='xiaohong'
check约束: age between 18 and 70 and gongzi 1000 and 3000
use master
go
create database jylt
on (
name=jylt,
filename='e:\db\jylt.mdf',
size=4,
filegrowth=100%,
maxsize=1024)
log on(
name=jylt_log,
filename='e:\db\jylt_log.ldf',
size=4,
filegrowth=100%)
go
use jylt
go
create table t_user
(
uid int primary key identity(1,1) not null,
ulname varchar(50) not null,
ulpwd varchar(50) not null,
unichen varchar(50) null,
uname varchar(50) null,
uaddress varchar(200) null,
usex int ,
utelephone varchar(50) null,
uhomepage varchar(200) null,
uimageurl varchar(200) null,
usignature varchar(200) null
)
go
create table t_reply
(
rid int not null primary key,
uid int foreign key references t_user(uid) ,
rtitle varchar(50),
rcontent varchar(max) not null,
rdatetime datetime default getdate()
)
go
create table t_board
(
bid int primary key not null,
bname varchar(50) not null,
bimgurl varchar(200) null,
binfo varchar(200) null
)
go
create table t_topic
(
tid int primary key not null,
ttitle varchar(50) not null,
tcontent varchar(max) not null,
tdatetime datetime default getdate(),
uid int foreign key references t_user(uid),
tview int default 0,
bid int references t_board(bid)
)
go
posted on 2010-07-06 09:14 Henry_Wang 阅读(537) 评论(0) 编辑 收藏 举报