Oracle displays the user's table names, Table Comments, field names, field comments, whether it is empty, field type, and oracle fields.

Source: Internet
Author: User

Oracle displays the user's table names, Table Comments, field names, field comments, whether it is empty, field type, and oracle fields.

-- Oracle: view all the table names, Table Comments, field names, field comments of the user, whether the table is empty, and select distinct TABLE_COLUMN of the field type. *, TABLE_NALLABLE.DATA_TYPE, TABLE_NALLABLE.NULLABLE from (select distinct utc. table_name, utc. comments table_comments, ucc. column_name, ucc. comments column_comments from user_tab_comments utc, user_col_comments ucc where utc. table_name = ucc. table_name and utc. table_name not like '% _ B' and utc. table_name not like '% _ Z' and utc. table_name not like '% 1%') TABLE_COLUMN, (select distinct table_name, column_name, nullable, DATA_TYPE from user_tab_cols where table_name not like '% _ B' and table_name not like '% _ Z' and table_name not like' % 100 ') TABLE_NALLABLE where TABLE_COLUMN.column_name = tables and TABLE_COLUMN.TABLE_NAME = TABLE_NALLABLE.table_name -- and TABLE_COLUMN.column_comments like '% category name %' and category like '% dictionary %'; -- remove Cartesian multiple times


How can I query the field types, field comments, and field names in an oracle table?

You can use the following statement:
SELECT B. column_name -- field name
, B. data_type -- field type
, B. data_length -- Field Length
, A. comments -- field comment
FROM user_col_comments
, All_tab_columns B
WHERE a. table_name = B. table_name and
A. table_name = 'table _ name ';

PS:
Table_name is case sensitive.

Query all the field names in the table with known table names in oracle. Check whether each field is a primary key, a foreign key, or an empty SQL statement,

Query all the columns and their attributes of a table:
Select t. *, 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 = women;
Query the table's primary key:
Select cu .*
From user_cons_columns cu, user_constraints au
Where cu. constraint_name = au. constraint_name and au. constraint_type = 'p' and au. table_name = women;
Search for the table's foreign key (including the name, referenced table name, and corresponding key name. The following is a multi-step query ):
Select * from user_constraints c where c. constraint_type = 'r' and c. table_name = women
Query the names of Columns with foreign key constraints:
Select * from user_cons_columns cl where cl. constraint_name = foreign key name;
Query the column name of the key of the referenced table:
Select * from user_cons_columns cl where cl. constraint_name = foreign key reference table key name;

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.