Home  >  Article  >  Database  >  How to query the total number of tables in Oracle

How to query the total number of tables in Oracle

WBOY
WBOYOriginal
2022-05-10 16:56:0323187browse

In Oracle, you can use the SELECT statement to query the total number of tables. This statement is used to select data from the database. When used in conjunction with COUNT(), you can query the number of tables under the user. The syntax is " SELECT COUNT(1) FROM USER_TABLES;".

How to query the total number of tables in Oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to query the total number of tables in oracle

Query the number of tables under the user

SELECT COUNT(1) FROM USER_TABLES;

Query the number of fields in the tables under the user

SELECT COUNT(1)
  FROM USER_COL_COMMENTS C
 WHERE EXISTS
 (SELECT 1 FROM USER_TABLES T WHERE T.TABLE_NAME = C.TABLE_NAME);

Number of query table records

SELECT T.TABLE_NAME, T.NUM_ROWS, T.BLOCKS, T.EMPTY_BLOCKS
  FROM USER_TABLES T;

Query table remarks

SELECT TABLE_NAME, TABLE_TYPE, COMMENTS
  FROM USER_TAB_COMMENTS
 WHERE COMMENTS LIKE '%字典%'

Space occupied by query table

analyze table T_DATA compute statistics;
 
SELECT NUM_ROWS , AVG_ROW_LEN
  FROM USER_TABLES
 WHERE TABLE_NAME = 'T_DATA';
 
SELECT SEGMENT_NAME, SUM(BYTES) / 1024 / 1024
  FROM USER_EXTENTS
 GROUP BY SEGMENT_NAME;

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to query the total number of tables in Oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is oracle emNext article:What is oracle em