第四课笔记:
字段的数据类型
字符型 N开头unicode编码(对不同语言间转换更支持单长度交非unicode更小)
系统表
用户定义表
临时表
分区表
保证数据完整性
6.设置标志字段
7 使用默认值
8 修改表
9、用户自定义数据类型
10、使用规则创建绑定
11、解除和删除规则
12、数据关系图
------------------------------------------------------------------------------------------------------------
---临时表
create table #test
(
id int not null,
name nvarchar(10) null,
adress nvarchar(50) null
)
--数据库看不到 但能查。 只对当前用户可见 新建查询就没了
select * from #test
--全局临时表 新建查询也能查
create table ##test
(
id int not null,
name nvarchar(10) null,
adress nvarchar(50) null
)
-----------用存储过程改表名
exec sp_rename 'mytest1','rename_mytest1'
-----------加列
alter table rename_mytest1
add c_added int null
----------删
alter table rename_mytest1
drop column c_added
----------改列名
exec sp_rename 'rename_mytest1.c2','c存储过程改的','column'
----------改列属性
alter table rename_mytest1
alter column c存储过程改的 int null
----------------------规则
--创建
create rule sorce
as
@value between 0 and 100
--存储过程绑定到列
sp_bindrule sorce,'rename_mytest1.c1'
--先解除才能删点规则
--解除
sp_unbindrule 'rename_mytest1.c1'
--删除
drop rule sorce