SQL Server and Oracle system tables get table name names and comments for columns

Source: Internet
Author: User

Data from the database in the work to export, but found that the exported Excel column names are field names (in English), to collect data on how to change the field name to Chinese names, and found that Oracle and SQL Server (SQLSERVER2008R2) is different, as follows:

SQL Server database:

system table:

---Get information about a table
SELECT * from SYS. OBJECTS
(Description: Name: Table name object_id: ID of table)

---Get information about a column
SELECT * from SYS. COLUMNS
(Description: Name: Column name object_id: Table ID column_id: Column ID)

---Get description information for a field
SELECT * from SYS. Extended_properties
(Description: major_id: The ID of the table minor_id: Column ID Value: The description of the field is the field comment)

---Get query statements for table name, column name, column description

SELECT a.name as ' table name ', b.name as ' column name ', C.value as ' column description '
From SYS. OBJECTS A left JOIN SYS. COLUMNS B on a.object_id=b.object_id
Left JOIN SYS. Extended_properties C on a.object_id=c.major_id

Oracle Database:

system table:

---Get the table name, column name, column description, field comments (if you query the field comments in a table in Oracle, you just need to query the table)
SELECT * from User_col_comments
(Description: table_name: Table name column_name: Field name comments: Field description is field comment)

---table describes the relevant information
SELECT * FROM User_tab_cols
(Description: table_name: Table name column_name: Field name)

SQL Server and Oracle system tables get table name names and comments for columns

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.