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'