Oracle queries table information to obtain table fields and field comments. oracle Fields

Source: Internet
Author: User

Oracle queries table information to obtain table fields and field comments. oracle Fields

Obtain table fields:

Select * from user_tab_columns where Table_Name = 'user table' order by column_name

Get table comments:

Select * from user_tab_comments where Table_Name = 'user table' order by Table_Name

Obtain field comments:

Select * from user_col_comments where Table_Name = 'user table' order by column_name/* Get table: */select table_name from user_tables; // select table_name from all_tables of the current user table; // All users' tables select table_name from dba_tables; // including the system table select table_name from dba_tables where owner = 'zfxfzb'/* user_tables: table_name, tablespace_name, role, and other dba_tables: ower, table_name, tablespace_name, last_analyzed, and other all_tables: ower, tabl E_name, tablespace_name, last_analyzed, and other all_objects: ower, object_name, subobject_name, object_id, created, last_ddl_time, timestamp, status, etc. * // * to obtain table fields: */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, nulla Ble, column_id, etc. values: ower, table_name, column_name, data_type, data_length, data_precision, data_scale, region, column_id, etc. values: ower, table_name, column_name, data_type, data_length, data_precision, data_scale, nullable, column_id, etc. * // * obtain the table comment: */select * from user_tab_comments/* user_tab_comments: table_name, table_type, comments, and dba_tab_comments, all_tab_comments, these two columns have more ower columns than user_tab_comments.. * // * Obtain the field comment: */select * from user_col_comments/* user_col_comments: table_name, column_name, and comments. dba_col_comments and all_col_comments are corresponding to the field comment. These two columns have ower columns greater. */

How can I use SQL statements to query Table comments and other information of oracle?

Reading table/field remarks in Oracle
Oracle uses comment on table/comment on column to append TABLE/field remarks.

Create table "MR_DEPT "(
"DEPT_ID" number not null,
"PARENT_ID" NUMBER,
"DEPT_NAME" CHAR (20) not null,
"STATUS" number default 1 not null,
Primary key ("DEPT_ID ")
);

Comment on table "MR_DEPT" IS 'department table ';
Comment on column "MR_DEPT". "DEPT_ID" IS 'department number ';
Comment on column "MR_DEPT". "PARENT_ID" IS 'higher-level department no ';
Comment on column "MR_DEPT". "DEPT_NAME" IS 'department name ';
Comment on column "MR_DEPT". "STATUS" IS 'status ';

After the remarks are added, how can I retrieve them in the query?

Query table remarks
SELECT
TABLE_NAME,
TABLE_TYPE,
COMMENTS
FROM
USER_TAB_COMMENTS
WHERE
TABLE_NAME = 'Mr _ DEPT;

Query the remarks of a field

SELECT
TABLE_NAME,
COLUMN_NAME,
COMMENTS
FROM
USER_COL_COMMENTS
WHERE
TABLE_NAME = 'Mr _ DEPT;
Reference: hi.baidu.com/..c.html

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.

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.