-
oracle database:
Query all users
select * from all_users
-- where USERNAME like 'sys_%'
Query all table information and query according to user
SELECT * FROM all_tables
--WHERE OWNER = '' ORDER BY TABLE_NAME;
Count the number of tables and the amount of data recorded in the tables for a certain user
SELECT count(table_name),sum(num_rows) FROM all_tables WHERE OWNER = ''
Statistics table data size (M)
select c.segment_name,b.TABLE_NAME, c.bytes,round(c.bytes / 1024 / 1024, 2 )|| 'M' from
(SELECT table_name FROM all_tables
WHERE OWNER = '' ORDER BY TABLE_NAME
) b
LEFT JOIN user_segments c on c.segment_name = b.TABLE_NAME and segment_type = 'TABLE'
2.mysql database:
Query all table information
select *
from
information_schema.tables
where
table_schema='当前数据库'
#table_rows是记录数
Or if you just want to see the table name, you can use
show tables
Query information with empty field annotations
select
column_name,
column_comment,
table_name
from information_schema.columns
where table_schema = '当前数据库'
and (column_comment is null or column_comment ='')
View field annotation information of a single table
show full columns from 表名;
Query table data length size
SELECT
table_comment,
table_name,
concat( round(DATA_LENGTH / 1024 / 1024, 2 ), 'M' )
FROM
information_schema.TABLES
WHERE
table_schema = '当前数据库'
3. Dameng database:
Query table information under a certain mode
select * from sys.dba_tables where owner = '模式名'
--或者
select * from all_tables where owner = '模式名'
Dameng handles CLOB types:
dbms_lob.substr(clobcolumn,4000), intercept the CLOB field;
Dameng handles TEXT type:
convert(varchar(5000),TEXT field), process the TEXT type
Remove the non-numeric decimal point part in heji:
SELECT
heji,
REGEXP_REPLACE(heji, '[^0-9\.]+', '') AS stripped_column
FROM
"test"."test";
4、prostgreSQL
Query table data volume, estimated value, inaccurate, accurate data is only one table statistics
(The statistics collector keeps track of roughly how many rows are "eventful" at any time (not deleted or discarded by later updates). Under heavy events, this value may be slightly off, but is usually a good estimate. , can also show how many rows have expired)
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;