Count the number of tables in the system and query the field information of all tables

Source: Internet
Author: User

Count the number of tables in the system and query the field information of all tables -- count the number of tables in the system: -- table description field: -- required field: Name, Code, Commente select lower (. TABLE_NAME) | '-' | B. comments, lower (. TABLE_NAME), B. comments from user_tables a, user_tab_comments B where. TABLE_NAME = B. TABLE_NAME order by B. comments,. TABLE_NAME; -- query the field information of all tables. -- Name, Code, Data Type, Length, P, F, comments select. table_name, t. comments,. COLUMN_ID, nvl (B. comments, B. column_name), B. column_name,. DATA_TYPE, case when. DATA_TYPE = 'varchar2' then. DATA_TYPE | '(' |. DATA_LENGTH | ')' when. DATA_TYPE = 'date' then'' when. DATA_TYPE = 'number' and. DATA_SCALE is not null then. DATA_TYPE | '(' |. DATA_PRECISION | ',' |. DATA_SCALE | ')' when. DATA_TYPE = 'number' and. DATA_SCALE is null then. DATA_TYPE | '(' |. DATA_LENGTH | ') 'else' end case, case when (select nvl (count (1), 0) from user_cons_columns c, user_constraints d where d. constraint_name = c. constraint_name and d. constraint_type = 'p' and c. table_name =. table_name and c. column_name =. column_name) = 1 then nvl (select d. constraint_name from user_cons_columns c, user_constraints d where d. constraint_name = c. constraint_name and d. constraint_type = 'p' and c. table_name =. table_name and c. column_name =. column_name), '') else'' end case from user_tab_cols a, user_col_comments B, user_tab_comments t where. TABLE_NAME = B. table_name and. COLUMN_NAME = B. column_name and. table_name = t. table_name order by. table_name,. COLUMN_ID;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.