T-SQL数据库规则约束及默认值设置学习笔记
2007-04-16 14:06
399 查看
create database test1
go
use test1
create table table1
(
book_ID int primary key not null,
book_name varchar(50) not null,
book_price varchar(100) not null,
book_type varchar(50) not null,
master_phone varchar(100) not null
)
go
create default master_phone as '(000)00000000'
go
exec sp_bindefault master_phone,'table1.master_phone'
insert into table1 values('1','仙剑奇侠传','50','科幻小说','(028)81776327')
insert into table1 (book_ID,book_name,book_price,book_type) values('2','网络经济学','80','网络教材')
select * from table1
go
--默认值设置成功!
create rule book_type_rule as @book_type in ('科幻小说','网络教材','文学读本','恐怖小说','言情小说')
go
exec sp_bindefault book_type_rule,'table1.book_type'
go
--创建规则约束成功!
--打完收功....
drop table table1
drop database test1
go
use test1
create table table1
(
book_ID int primary key not null,
book_name varchar(50) not null,
book_price varchar(100) not null,
book_type varchar(50) not null,
master_phone varchar(100) not null
)
go
create default master_phone as '(000)00000000'
go
exec sp_bindefault master_phone,'table1.master_phone'
insert into table1 values('1','仙剑奇侠传','50','科幻小说','(028)81776327')
insert into table1 (book_ID,book_name,book_price,book_type) values('2','网络经济学','80','网络教材')
select * from table1
go
--默认值设置成功!
create rule book_type_rule as @book_type in ('科幻小说','网络教材','文学读本','恐怖小说','言情小说')
go
exec sp_bindefault book_type_rule,'table1.book_type'
go
--创建规则约束成功!
--打完收功....
drop table table1
drop database test1
相关文章推荐
- 一步步学习微软InfoPath2010和SP2010--第五章节--添加逻辑和规则到表单(3)--使用函数设置默认值
- 一步步学习微软InfoPath2010和SP2010--第五章节--添加逻辑和规则到表单(3)--使用函数设置默认值
- Cadence Allegro学习之层叠设置+约束规则管理器+线宽规则设置+线距规则设置
- shell的学习笔记——变量的设置规则
- T-SQL数据库约束学习笔记
- 约束理论学习笔记---作业指标VS财务指标
- python-IDE-spyder自动设置时间,作者、联系方式的方法--python学习笔记27
- web开发-阿里云服务器自定义镜像设置和快照设置-学习笔记十一
- Linux 学习笔记_11_2_Linux网络设置(下)
- 2014.11.22 差分约束学习笔记
- C++数组初始化规则的学习笔记
- 伸缩控件dockManager详细设置 DXperience学习笔记
- Matlab学习笔记-颜色设置
- 规则引擎中如何审核发布规则学习笔记
- MySQL学习笔记4:完整性约束
- MySQL学习笔记(四)修改数据表约束
- 孙鑫VC学习笔记:第十三讲 (二) 设置文档标题
- maven学习笔记--设置代理服务器
- java学习笔记1——环境设置
- 遗传算法与直接搜索工具箱学习笔记 三-----目标函数的约束