怎么判断字段为Integer

[复制链接]
查看11 | 回复9 | 2009-7-22 09:30:00 | 显示全部楼层 |阅读模式
all_tab_cols中 data_type没有Integer值啊,好像全部认成是number()了.
还可以从哪里查询?
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
顶起来一下,没有人知道么?
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
oracle 里没有integer
int integer会被自动转型为number
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
那怎么办,如何才能取出integer?
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
为什么要Integer?用number不是很好啊。
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
需要从all_tab_cols中取出数据库所有表的信息。取出字段名,类型,长度,精确度。没办法找出来Integer
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
selecta.table_name,a.column_name,a.NULLABLE,a.DATA_DEFAULT,a.data_type,b.CONSTRAINT_TYPE from
(
select table_name,column_name,NULLABLE,DATA_DEFAULT ,
case
when data_type='VARCHAR2' then data_type||'('||data_length||')'
when data_type='DATE' then data_type
when data_type='NUMBER' then data_type||'('||DATA_PRECISION||')'
when data_type='VARCHAR2' then data_type||'('||data_LENGTH||')'
when data_type='CHAR' then data_type||'('||data_LENGTH||')'
when data_type='CLOB' then data_type
when data_type='INTERGER' then data_type
end data_type
from all_tab_cols
where owner='OTAS' and table_name like 'T_%'
) a,
(
select c.table_name,d.column_name pk_column,c.CONSTRAINT_TYPE from all_constraints c,all_cons_columns d
where c.constraint_name=d.constraint_name and c.constraint_type'C'and c.table_name like 'T_%' and c.owner='OTAS'
) b
where a.table_name=b.table_name(+)and a.column_name=b.pk_column(+)
order by table_name;
发现没有integer
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
number(*,0)就是整数
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
number(p,s)
s是all_tab_cols中的哪个字段表示的,
看了半天是DATA_SCALE吗?
回复

使用道具 举报

千问 | 2009-7-22 09:30:00 | 显示全部楼层
做了个实验,搞定了。谢谢!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行