C/C++教程

oracle获取表结构

本文主要是介绍oracle获取表结构,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

select t.COLUMN_NAME,
Decode(t.DATA_TYPE,'NUMBER',DATA_TYPE||'('||DATA_LENGTH||','||DATA_PRECISION||')',DATA_TYPE||'('||DATA_LENGTH||')') DATA_TYPE,
t.NULLABLE,
t.COLUMN_ID,
c.COMMENTS
from user_tab_columns t, user_col_comments c
where t.table_name = c.table_name
and t.column_name = c.column_name
and t.table_name = 'MENZSF'
order by t.COLUMN_ID ;



select 'alter table MENZSF add ('|| t.COLUMN_NAME||' ' ||
Decode(t.DATA_TYPE,'NUMBER',DATA_TYPE||'('||DATA_LENGTH||','||DATA_PRECISION||')',DATA_TYPE||'('||DATA_LENGTH||')') ||');',
t.NULLABLE,
t.COLUMN_ID,
c.COMMENTS
from user_tab_columns t, user_col_comments c
where t.table_name = c.table_name
and t.column_name = c.column_name
and t.table_name = 'MENZSF'
order by t.COLUMN_ID ;

这篇关于oracle获取表结构的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!