Sql Server 生成数据字典
use Dbname
go
select
[表名]=c.Name,
[表说明]=isnull(f.[value],''),
[列名]=a.Name,
[列序號]=a.Column_id,
[标识]=case when is_identity=1 then '√' else '' end,
[主鍵]=case when exists(select 1 from sys.objects x join sys.indexes y on x.Type=N'PK' and x.Name=y.Name
join sysindexkeys z on z.ID=a.Object_id and z.indid=y.index_id and z.Colid=a.Column_id)
then '√' else '' end,
[类型]=b.Name,
[字节数]=case when a.[max_length]=-1 and b.Name!='xml' then 'max/2G'
when b.Name='xml' then '2^31-1字節/2G'
else rtrim(a.[max_length]) end,
[长度]=case when ColumnProperty(a.object_id,a.Name,'Precision')=-1 then '2^31-1'
else rtrim(ColumnProperty(a.object_id,a.Name,'Precision')) end,
[小数]=isnull(ColumnProperty(a.object_id,a.Name,'Scale'),0),
[是否为空]=case when a.is_nullable=1 then '√' else '' end,
[列说明]=isnull(e.[value],''),
[默认值]=isnull(d.text,'')
from
sys.columns a &
相关文档:
SQL Server里的 ISNULL 与 Oracle 中的 NULLIF不同:
SQL Server 中有两个参数,语法:
ISNULL(check_expression, replacement_value)
check_expression 与 replacement_value 数据类型必须一致
如果 check_expression 为 NULL,则返回 replacement_v ......
转载自:http://www.cnblogs.com/leonbao/archive/2008/03/07/1094821.html
关于SQL Server数据库设计的感悟,请指教
有问题的时候,我经常回来博客园寻找答案,久而久之,总结了一些东西。
妄自菲薄,请大家多指出错误,并给出意见
数据库设计三范式基本原则
第一范式:数据库表中的字段都是单一属性的,不可再分。这 ......
一、适合读者对象:数据库开发程序员,数据库的数据量很多,涉及到对SP(存储过程)的优化的项目开发人员,对数据库有浓厚兴趣的人。
二、介绍:在数据库的开发过程中,经常会遇到复杂的业务逻辑和对数据库的操作,这个时候就会用SP来封装数据库操作。如果项目的SP较多,书写又没有一定的规范,将会影响以后的系统维护 ......
ch02
--3-4
select * from orders
where 'México D.F.' in
(select City
from Customers
where Orders.CustomerID = Customers.CustomerID )
--3-5
select * from orders
where 'usa' =
(select Country
from Customers
where Orders.CustomerID = Customers.CustomerID )
--4-1
select * from or ......
优化器在形成执行计划时需要做的一个重要选择是如何从数据库查询出需要的数据。对于SQL语句存取的任何表中的任何行,可能存在许多存取路径(存取方法),通过它们可以定位和查询出需要的数据。优化器选择其中自认为是最优化的路径。
在物理层,oracle读取数据,一次读取的最小单位为数据库块(由多个连续的操作系统块组成 ......