数据库查表空间-Oracel、Vertica

Oracel数据库常用语句:

--查看用户和默认表空间的关系
select username,default_tablespace from dba_users;
--查看当前用户能访问的表
select * from user_tables;
--Oracle查询用户表
select * from user_all_tables;

--Oracle查询用户视图
select * from user_views;
--查询所有函数和储存过程:
select * from user_source;
--查询所有用户:
select * from all_users; -- select * from dba_users

--查看当前用户连接:
select * from v$Session;

--查看用户角色
SELECT * FROM USER_ROLE_PRIVS;

--查看当前用户权限:
select * from session_privs;

--查看所有用户所拥有的角色
SELECT * FROM DBA_ROLE_PRIVS;

--查看所有角色
select * from dba_roles;

--查看数据库名
SELECT NAME FROM V$DATABASE;

--查看所有表空间使用情况

方法一 查询当前所有表空间的使用情况:
select a.file_id "FileNo", a.tablespace_name "Tablespace_name", a.bytes "Bytes", a.bytes - sum(nvl(b.bytes, 0)) "Used", sum(nvl(b.bytes, 0)) "Free", sum(nvl(b.bytes, 0)) / a.bytes * 100 "%free" from dba_data_files a, dba_free_space b where a.file_id = b.file_id(+) group by a.tablespace_name, a.file_id, a.bytes order by a.tablespace_name;

方法二 查询所有单表所占用空间情况:
select round(sum(BYTES)) from dba_segments; -- select round(sum(BYTES)) from user_segments;

Vertica 常用语句

-- 查询数据库是否有等待
select * from resource_queues where node_name=(select node_name from nodes order by node_name limit 1) order by queue_entry_timestamp desc;

-- 查看当前执行任务
select * from sessions

-- 查询所有数据库中的表(vertica中所有的表存在于projection,不能使用传统的all_tables进行查询)
select *from projections

-- 查询表字段及注释信息
SELECT t3.anchor_table_name AS Table_name, SUBSTR (t1.object_name, INSTR (t1.object_name, '.', 1) + 1) AS Column_name, t1.comment AS comment FROM comments t1, projections t3 WHERE SUBSTR (t1.object_name, 1, INSTR (t1.object_name, '.', 1) - 1) = t3.projection_name AND t1.object_type = 'COLUMN' ORDER BY t3.anchor_table_name;
-- 查询数据库空间使用情况(可查表级和用户级)
select * from v_monitor.projection_storage

posted on   bug耗子  阅读(1060)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示