读取Oracle列信息如何判断类型?
1.
select user_col_comments.comments,
user_tab_columns.column_name,
user_tab_columns.data_type,
user_tab_columns.data_scale
from user_tab_columns, user_col_comments
where user_tab_columns.table_name = user_col_comments.table_name
and user_tab_columns.column_name = user_col_comments.column_name
and lower(user_tab_columns.table_name) = lower('mkt_guider_calender')
order by user_tab_columns.column_id
如果列的类型为整形和浮点形那么data_type都是NUMBER,请问这种类型是如何区分的?2.column_name定义的时候是(CYear),但是查询出来的都是大写(CYEAR)
1.
select user_col_comments.comments,
user_tab_columns.column_name,
user_tab_columns.data_type,
user_tab_columns.data_scale
from user_tab_columns, user_col_comments
where user_tab_columns.table_name = user_col_comments.table_name
and user_tab_columns.column_name = user_col_comments.column_name
and lower(user_tab_columns.table_name) = lower('mkt_guider_calender')
order by user_tab_columns.column_id
如果列的类型为整形和浮点形那么data_type都是NUMBER,请问这种类型是如何区分的?2.column_name定义的时候是(CYear),但是查询出来的都是大写(CYEAR)
解决方案 »
- 有谁知道哪本oracle教程书比较全面、比较好的?
- 表分区的自动并行问题,高手请进
- 大姐求助:select to_char(0.5) from dual 结果是.5 ,如何得到0.5,前面有个零?
- oracle的基础问题
- 关于oracle客户端的安装!总是提示“加载数据库错误”
- 在线问一SQL语句,该什么写?
- 如果现在oracle的安装目录和以前的安装目录不一样,在保留以前的oradata\目录的情况下,如何有效恢复所有数据???
- linux下安装oracle 8 ,安装界面为乱码
- 求助!关于INSET INTO的用法!
- 请问各大侠,oracle如何入门呢?
- 进程存储与存储过程的区别?
- exited knalfgetscnfilter 是怎么回事
oracle没有单独的区分他们的 number(m,n) m表示总的位数 n表示小数点后的位数oracle存的都是大写的
除非你用双引号 "CYear" 这样oracle就会严格的区分大小写
case data_length when 38 then 'int' end, case data_scale when 129 then real end2. 利用lower和upper处理一下
numeric(p,s):完全映射至number(p,s),p默认为38
decimal(p,s)或dec(p,s):完全映射至number(p,s)
integer或int:完全映射至number(38)
smallint:完全映射至number(38)
float(b):映射至number类型
double precision:映射至number类型
real:映射至number类型
create table tb(
col_1 number(5,5),
col_2 numeric(5,5),
col_3 decimal(5,5),
col_4 int,
col_5 smallint,
col_6 double precision,
col_7 real,
col_8 float);
--
select column_name,data_type,data_length,data_precision,data_scale
from user_tab_columns
where table_name='TB'; COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_PRECISION DATA_SCALE
------------------------------ -------------------------------------------------------------------------------- ----------- -------------- ----------
COL_1 NUMBER 22 5 5
COL_2 NUMBER 22 5 5
COL_3 NUMBER 22 5 5
COL_4 NUMBER 22 0
COL_5 NUMBER 22 0
COL_6 FLOAT 22 126
COL_7 FLOAT 22 63
COL_8 FLOAT 22 126
--
从data_length这列看,上面所有的数值类型长度都是22,说明所有的类型都映射至了number类型。