Some statements related to the Oracle query table structure

Source: Internet
Author: User

Select * from all_tab_comments; -- select * from user_tab_comments; -- Query all tables and views of the current user. select * from all_col_comments; -- query the column names and comments of all tables of the current user. select * from user_col_comments; -- query the column name and comment of the current user's table select * from all_tab_columns; -- query the structure information of the columns of all users's tables (no remarks) select * from user_tab_columns; -- query the structure information of the columns in the table of the current user (no remarks) -- query the trust information of a table (including column name, data type, length, null, primary key, foreign key, and remarks) SELECT USER_TAB_COLS.COLUMN_NAME as column name, USER_TAB_COLS.DATA_TYPE as data type, USER_TAB_COLS.DATA_LENGTH as length, whether USER_TAB_COLS.NULLABLE as is null, case when (SELECT col. column_name FROM user_constraints con, user_cons_columns col where con. constraint_name = col. constraint_name and con. constraint_type = 'p' and col. table_name = 'table name' and col. column_name = partition) = USER_TAB_COLS.COLUMN_NAME THEN 'y' ELSE 'n' END as whether the primary key is used, case when (select count (*) from user_constraints con, user_cons_columns col, (select t2.table _ name, t2.column _ name, t1.r _ constraint_name from user_constraints t1, user_cons_columns t2 where t1.r _ constraint_name = t2.constraint _ name and t1.table _ name = 'table name') r where con. constraint_name = col. constraint_name and con. r_constraint_name = r. r_constraint_name and con. table_name = 'table name' and col. column_name = USER_TAB_COLS.COLUMN_NAME)> 0 then 'y' else 'n' END as whether it is a foreign key, user_col_comments.comments as remarks FROM USER_TAB_COLS inner join user_col_comments on user_col_comments.TABLE_NAME = USER_TAB_COLS.TABLE_NAME and comment = orders and USER_TAB_COLS.TABLE_NAME = 'table name' order by comment;

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.