ORACLE查询表的字段名几种方式

来源:互联网 发布:js简单计算器代码 编辑:程序博客网 时间:2024/06/05 19:31
1、oracle查询表的字段名并连接成用逗号隔开的字符串 
select max(substr(SYS_CONNECT_BY_PATH(COLUMN_NAME, ','),2)) col from ( 
select 'a.'||COLUMN_NAME as COLUMN_NAME,column_id from sys.user_tab_columns  where table_name='ENTBT_ENT_INFO_OUT') 
start with column_id=1 
connect by column_id=rownum; 
2、oracle查询表的字段名 
select 'private String  '||T.COLUMN_NAME||'= null ;     //'||T.COMMENTS from sys.all_col_comments t 
where t.owner ='CIQAGENT' AND T.TABLE_NAME ='T_ENT_MONEY' 
3、oracle查询表的字段名并转成小写 
select ­
'BuildBtEntUsrInfoSbf.append("<'||Lower(REPLACE(T.COLUMN_NAME,'_',''))|| '>"+' 
|| 'BtEntUsrinfo[i]+' || '"</'||Lower(REPLACE(T.COLUMN_NAME,'_',''))|| '>");' 
from sys.all_col_comments t 
where t.owner ='DVNEWS' AND T.TABLE_NAME ='ORGBT_ENT_USR_IN' 
select
'BuildCtCerInfoSbf.append("<'||T.COLUMN_NAME|| '>"+'
|| 'CtCerInfo['||to_number(T.COLUMN_ID-1)||']+' || '"</'||T.COLUMN_NAME|| '>");'
from sys.user_tab_columns t
where T.TABLE_NAME ='CT_CER'
select column_id,'digester.addCallMethod("message/ctsf/'||Lower(replace(T.COLUMN_NAME,'_',''))||'","set'||T.COLUMN_NAME||'",0 );' 
  from sys.user_tab_columns t ­
where t.table_name = 'CT_SF' order by t.COLUMN_ID ­
select ­
       replace('OutEntInfoSbf.append(OutEntInfo.get' || T.COLUMN_NAME || '());'|| 
       chr(13)||'OutEntInfoSbf.append(",");','""','') ­
  from sys.user_tab_columns t 
where t.table_name = 'BT_ENT_INFO' 
order by t.COLUMN_ID
select 
       'if(!Utility.chgnulltospace(OutEntInfo.get' || T.COLUMN_NAME || '()).equals(""))'
      ||chr(13)||'{'
      ||chr(13)||'OutEntInfoSbf.append("'||T.COLUMN_NAME||'=");'
      ||chr(13)||'OutEntInfoSbf.append("''");'
      ||chr(13)||'OutEntInfoSbf.append(Utility.chgnulltospace(OutEntInfo.get' || T.COLUMN_NAME || '()));'
      ||chr(13)||'OutEntInfoSbf.append("''");'
      ||chr(13)||'OutEntInfoSbf.append(",");'
      ||chr(13)||'}'
  from sys.user_tab_columns t
where t.table_name = 'CT_SF'
order by t.COLUMN_ID 
select '//' || t.COMMENTS || chr(13) || 'private String  ' || b.COLUMN_NAME ||
       '= null ;'
  from sys.all_col_comments t, user_tab_columns b
 where t.table_name= b.TABLE_NAME and t.column_name=b.COLUMN_NAME
   and t.owner = 'DVCOMM'
   AND T.TABLE_NAME = 'DVINSP_ORI_INV_INFO'
 order by b.COLUMN_ID
select
'PerInfo.set'||T.COLUMN_NAME
|| '(Utility.chgnull(rest.getString("'||T.COLUMN_NAME||'")))'||';'
from sys.user_tab_columns t
where T.TABLE_NAME ='S_PER_INFO' order by t.COLUMN_ID
select
'sbf.append("<'||T.COLUMN_NAME|| '>"+'
|| 'Utility.chgnull(PerInfo.get'||T.COLUMN_NAME||'())+' || '"</'||T.COLUMN_NAME|| '>");'
from sys.user_tab_columns t
where T.TABLE_NAME ='S_PER_INFO' order by t.COLUMN_ID
0 0