數據庫查表空間-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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM