oracle query all the tables under the current user, including all fields

oracle query all the tables under the current user, including all fields

background:

Two days ago I received a demand to do a show all the table names, table notes, table data, table number field, click the View button to see the field names and comments, support for export.

In Oracle, the use of available view USER_TABLES view the current user what table, how much data there:

table_name: table name, field_num: table number of fields, comments: Note to Table, count_rows (table_name): Statistics Data

SELECT * FROM USER_TABLES;

USER_TAB_COLUMNS: All columns in the table

SELECT * FROM USER_TAB_COLUMNS

user_columns: the current user can query all the fields in the table, and notes, col_name: field names, comments: Field Comment

We use domestically Xu Gu database, grammar and similar oracle, sql concrete realization of the following:

select  t.table_name as "表名",t.field_num as "字段统计",t.comments as "表备注",count_rows(table_name)  "数据统计" ,c.col_name as "字段名",c.comments as "字段备注"
from user_tables t inner join user_columns c on c.table_id = t.table_id order by t.table_name asc;

Screenshot results:

Guess you like

Origin www.cnblogs.com/fxsenblog/p/11691335.html