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
轉載于:https://www.cnblogs.com/netact/archive/2010/07/06/1771874.html
總結
以上是生活随笔為你收集整理的SQL Server 相关create操作语句的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 远程服务器虚拟显示器配置方法
- 下一篇: MySQL数据库添加一个字段