-
oracle数据库:
查询所有用户
select * from all_users
-- where USERNAME like 'sys_%'
查询所有表信息,可根据用户查询
SELECT * FROM all_tables
--WHERE OWNER = '' ORDER BY TABLE_NAME;
统计某个用户下表数量、表记录数据量
SELECT count(table_name),sum(num_rows) FROM all_tables WHERE OWNER = ''
统计表数据量大小(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数据库:
查询所有表信息
select *
from
information_schema.tables
where
table_schema='当前数据库'
#table_rows是记录数
或者只想看表名可以用
show tables
查询字段注释为空的信息
select
column_name,
column_comment,
table_name
from information_schema.columns
where table_schema = '当前数据库'
and (column_comment is null or column_comment ='')
查看单表的字段注释信息
show full columns from 表名;
查询表数据长度大小
SELECT
table_comment,
table_name,
concat( round(DATA_LENGTH / 1024 / 1024, 2 ), 'M' )
FROM
information_schema.TABLES
WHERE
table_schema = '当前数据库'
3、达梦数据库:
查询某个模式下表信息
select * from sys.dba_tables where owner = '模式名'
--或者
select * from all_tables where owner = '模式名'
达梦处理CLOB类型:
dbms_lob.substr(clobcolumn,4000),对CLOB字段进行截取;
达梦处理TEXT类型:
convert(varchar(5000),TEXT字段) ,对TEXT类型进行处理
去除heji中非数字小数点部分:
SELECT
heji,
REGEXP_REPLACE(heji, '[^0-9\.]+', '') AS stripped_column
FROM
"test"."test";
4、prostgreSQL
查询表数据量,估计值,不准确,准确数据只是一个表一个表统计
(统计信息收集器随时大致跟踪有多少行是“事件的”(未被删除或被以后的更新废弃)。在繁重的事件下,此值可能会略有偏差,但通常是一个不错的估计值,还可以显示有多少行已失效)
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;