数据字典(SQL语句)
declare @tmp table
(
id int identity(1,1),
TableName varchar(100),
Column_name varchar(100),
Type varchar(50),
Lenght int,
Scale int,
Nullable varchar(1),
Defaults varchar(4000),
PrimaryKey varchar(1)
)
select iid = identity(int,1,1), * into #a from SysObjects where xtype = 'U'
declare @i int
declare @max int
declare @table varchar(100)
set @i = 1
select @max = max(iid) from #a
while @i <= @max
begin
select @table = name from #a where iid = @i
if @@rowcount > 0
begin
insert @tmp (TableName, Column_name, Type, Lenght, Scale, Nullable, Defaults,PrimaryKey)
select @table, a.name, c.name, a.length, a.xscale, case a.isnullable when 0 then 'N' else 'Y' end, isnull(d.text,''), case when x.PrimaryKey is null then '' else x.PrimaryKey end
from SysColumns a with(nolock)
inner join (select * from SysObjects with(nolock) where xtype = 'U' and id = object_id(@table)) b on a.id = b.id
inner join SysTypes c with(nolock) on a.xtype = c.xusertype
left join syscomments d with(nolock) on a.cdefault = d.id
left join
(select f.id, colid, 'Y' as PrimaryKey from SysIndexKeys f with(nolock), SysIndexes e, SysObjects g
where f.id = e.id and f.indid = e.indid and f.id = g.parent_obj and e.name = g.name
and g.xtype = 'PK' and g. parent_obj = object_id(@table)) x on a.id = x.id and a.colid = x.colid
end
set @i = @i + 1
end
select * from @tmp
相关文档:
Declare @T Table(
CFF_Loanno nvarchar(100),
BANK_Name_2 nvarchar(100),
CFF_code nvarchar(100),
CFF_date datetime,
CFF_amt decimal(18, 6),
......
字符串函数对二进制数据、字符串和表达式执行不同的运算。此类函数作用于CHAR、VARCHAR、 BINARY、 和VARBINARY 数据类型以及可以隐式转换为CHAR 或VARCHAR的数据类型。可以在Select 语句的Select 和Where 子句以及表达式中使用字符串函数。常用的字符串函数有:
  ......
我们要做到不但会写SQL,还要做到写出性能优良的SQL语句。
(1)选择最有效率的表名顺序(只在基于规则的优化器中有效):
Oracle的解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving table)将被最先处理,在from子句中包含多个表的情况下,你必须选择记录条数最少的表作为基础表。如 ......
微软的SQL SERVER提供了两种索引:聚集索引(clustered index,也称聚类索引、簇集索引)和非聚集索引(nonclustered index,也称非聚类索引、非簇集索引)……
<script type="text/javascript"></script>
(一)深入浅出理解索引结构
实际上,您可以把索引理解为一种特殊的目录。微软的SQ ......
---------数学函数 ---------------
1.绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
2.取整(大)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.取整(小)
S:select floor(-1.001) value
O:select floor(-1.001) value from ......