SELECT b.column_namecolumn_name-字段名,b.data_typedata_type-字段类型,b.data_length-字段长度,a.commentscomments-字段注释FROM user_col_commentsa,all_tab_columnsbWHERE a.table_name=b.table_nameanda.table_name=''table_name'';扩展资料:关于获取oracle表中所有需要的信息一、获取表字段:select*fromuser_tab_columnswhereTable_Name=''用户表''orderbycolumn_name二、获取表注释:select*fromuser_tab_commentswhereTable_Name=''用户表''orderbyTable_Name三、获取字段注释:select*fromuser_col_commentswhereTable_Name=''用户表''orderbycolumn_name/*获取表:*/selecttable_namefromuser_tables;//当前用户的表 selecttable_namefromall_tables;//所有用户的表selecttable_namefromdba_tables;//包括系统表selecttable_namefromdba_tableswhereowner=''zfxfzb''/*user_tables:table_name,tablespace_name,last_analyzed等dba_tables:ower,table_name,tablespace_name,last_analyzed等all_tables:wer,table_name,tablespace_name,last_analyzed等all_objects:ower,object_name,subobject_name,object_id,created,last_ddl_time,timestamp,status等*//* 获取表字段:*/select*fromuser_tab_columnswhereTable_Name=''用户表'';select*fromall_tab_columnswhereTable_Name=''用户表'';select*fromdba_tab_columnswhereTable_Name=''用户表'';/*user_tab_columns:table_name,column_name,data_type,data_length,data_precision,data_scale,nullable,column_id等all_tab_columns:ower,table_name,column_name,data_type,data_length,data_precision,data_scale,nullable,column_id等dba_tab_columns:ower,table_name,column_name,data_type,data_length,data_precision,data_scale,nullable,column_id等*//* 获取表注释:*/select*fromuser_tab_comments/*user_tab_comments:table_name,table_type,comments相应的还有dba_tab_comments,all_tab_comments,这两个比user_tab_comments多了ower列。获取字段注释:*/select*fromall_col_comments/*user_col_comments:table_name,column_name,comments相应的还有dba_col_comments,all_col_comments,这两个比user_col_comments多了ower列。
黄生锦2019-12-22 01:54:06