Queries the table name and remarks in the database and explains the Oracle database macro processing instances.

Source: Internet
Author: User

Queries the table name and remarks in the database and explains the Oracle database macro processing instances.

Explain the SELECT statement for querying table names and notes in the database and Oracle Database macro processing instances

A. table_name,

A. num_rows,

B .*

FROM

User_tables

JOIN user_tab_comments B on a. table_name = B. table_name

WHERE

Num_rows> 1

AND B. comments LIKE '% %'

ORDER

Num_rows;

Dba_tables: information about all tables in the system. You must have the DBA permission to query all_tables: information about the table with the permission of the current user (as long as you have any permissions on a table, you can see the table information in this view.) user_tables: The table information under the current user name. Therefore, in the preceding three views, user_tables has the smallest range. all_tables has a little more information, dba_tables displays the most information.
Some macro processing of Oracle database tables

For example, if you have a database table, how many tables have been created in this database? How many data entries does each table have? What fields does each table have? And field descriptions?

The following uses SQL to solve the above problems one by one:

-- All existing table names and descriptions select t. table_name, f. comments from user_tables t inner join user_tab_comments f on t. table_name = f. table_name

Note: The above fields (t. table_name, f. comments) and table names (user_tables and the other) do not need to be changed, just copy them;

To know how many pieces of data are there, just count the above result set.

-- Select a. num_rows, a. TABLE_NAME, B. COMMENTS from user_tables a, user_tab_comments B WHERE a. TABLE_NAME = B. TABLE_NAME order by TABLE_NAME
-- Specify the table fields and Chinese descriptions select t. table_name, t. column_name, t. comments from user_col_comments t where t. table_name = 'satisfaction _ SURVEY'

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.