Obtain the field information of the oracle table structure

Source: Internet
Author: User

Obtain the field information of the oracle table structure. select. column_id as column number,. column_name as column name,. data_type as type, decode (. data_type, 'number',. data_precision,. data_length) as length,. data_scale as decimal point, decode (e. uniqueness, 'unique', 'y', 'n') whether the as is UNIQUE, decode (e. key, 'y', 'y', 'n') is the primary key, f. comments as comment,. whether nullable as can be null,. data_default as default value: from user_tab_columns a, user_col_comments f, (select B. table_name, B. index_name, B. unique Ness, c. column_name, decode (d. constraint_name, NULL, 'n', 'y') key from user_indexes B, user_ind_columns c, (select constraint_name from user_constraints where constraint_type = 'P') d where B. index_name = c. index_name and B. index_name = d. constraint_name (+) ewhere. table_name = 'temptable' and. table_name = e. table_name (+) and. column_name = e. column_name (+) and. table_name = f. table_name and. column_nam E = f. column_nameorder by. column_id select TC. table_name, TC. column_name, TC. DATA_TYPE, TC. data_length, TC. data_precision, TC. nullable, TC. char_col_decl_length, decode (C. constraint_type, 'P', 'pk', 'U', 'unique', 'R', 'fk ', 'C', 'check', C. constraint_type) from USER_TAB_COLUMNS TC, USER_CONS_COLUMNS CC, user_constraints Cwhere TC. table_name = 'emp' and TC. table_name = CC. table_name (+) and TC. column_name = CC. colum N_name (+) and CC. constraint_name = C. constraint_name (+) select. column_name field name,. data_type data type,. data_length,. data_precision integer,. data_Scale decimal point,. nullable allows null values.. the default value of Data_default is B. comments standby note from user_tab_columns A, user_col_comments B where. COLUMN_NAME = B. column_name and. table_Name = B. table_Name and. table_Name = 'test': select table_name from user_tables; // select table of the current user _ Name from all_tables; // All users' tables select table_name from dba_tables; // including the system table select table_name from dba_tables where owner = 'user' user_tables: table_name, tablespace_name, struct and other dba_tables: ower, table_name, tablespace_name, struct and other all_tables: ower, table_name, tablespace_name, struct, and other all_objects: ower, object_name, struct, object_id, created, duration, timestamp, status, etc.: Select * from user_tab_columns where Table_Name = 'user table'; select * from all_tab_columns where Table_Name = 'user table'; select * from dba_tab_columns where Table_Name = 'user table'; user_tab_columns: table_name, column_name, data_type, data_length, data_precision, data_scale, nullable, column_id, etc. values: ower, table_name, column_name, data_type, data_length, data_precision, data_scale, nullable, column_id Mns: ower, table_name, column_name, data_type, data_length, data_precision, data_scale, nullable, column_id, etc. Obtain Table Comments: select * from user_tab_comments: table_name, table_type, comments -- corresponding to dba_tab_comments and all_tab_comments, which have more ower columns than user_tab_comments. Obtain field comments: select * from user_col_comments: table_name, column_name, comments

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.