`
liuxx.adam
  • 浏览: 79883 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

查询表结构(oracle)

阅读更多
1.简略:
select * from ALL_TAB_COLS A
where lower(A.Table_Name) = 't_s_pd_invest_prod_no'

2.详细
select A.COLUMN_NAME,
      
       decode(A.DATA_TYPE,
              'CHAR',
              A.DATA_TYPE || '(' || A.DATA_LENGTH || ')',
              'DATE',
              A.DATA_TYPE,
              'NUMBER',
              A.DATA_TYPE || '(' || A.DATA_PRECISION || ',' || A.DATA_SCALE || ')',
              'VARCHAR2',
              A.DATA_TYPE || '(' || A.DATA_LENGTH || ')') as DATA_TYPE,
       B.comments,
       decode(C.COLUMN_NAME, null, 'No', 'Yes') as Key,
       decode(A.NULLABLE, 'N', 'NOT NULL', 'Y', 'NULL') as NULLABLE
  from sys.user_tab_cols A,
       sys.user_col_comments B,
       (select col.column_name, c.table_name
          from user_constraints c, user_cons_columns col
         where c.constraint_name = col.constraint_name
           and c.constraint_type = 'P') C
where lower(A.TABLE_NAME) = 't_s_pd_invest_prod_no'
   and A.TABLE_NAME = B.table_name
   and A.COLUMN_NAME = B.column_name
   and A.Table_Name = C.TABLE_NAME(+)
   and A.COLUMN_NAME = C.COLUMN_NAME(+)
order by A.Column_Id
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics