oracle常用sql语句

喜夏-厌秋 提交于 2019-12-18 14:24:56
查看数据库版本

select version from Product_Component_Version where SUBSTR(PRODUCT,1,6) = ‘Oracle’

查询临时表空间信息

select TABLESPACE_NAME “表空间名称”,
round(TABLESPACE_SIZE / (1024 * 1024 * 1024), 2) “临时表空间大小(G)”,
round(ALLOCATED_SPACE / (1024 * 1024 * 1024), 2) “Allocated空间的大小(G)”,
round(FREE_SPACE / (1024 * 1024 * 1024), 2) “临时表空间大小(G)”
from dba_temp_free_space

查询表空间和索引表空间大小语句

SELECT a.tablespace_name “表空间名”,
total “表空间大小”,
free “表空间剩余大小”,
(total -free) “表空间使用大小”,
round(total/(102410241024), 2)“表空间大小(G)”,
round(free/(102410241024), 2)“表空间剩余大小(G)”,
round((total-free)/(102410241024), 2)“表空间使用大小(G)”,
round((total-free)/total,4)*100 “使用率%”
from (SELECT tablespace_name,SUM(bytes)free From dba_free_space GROUP BY tablespace_name)a,
(SELECT tablespace_name,SUM(bytes)total From dba_data_files GROUP BY tablespace_name)b
WHERE a.tablespace_name = b.tablespace_name and a.tablespace_name in (‘TBS_CPS_DATA’,‘TBS_CPS_INDX’)

查数据库块大小语句

select value/1024 from v$parameter where name = ‘db_block_size’

查看表空间大小

select segment_name as tablename , round(bytes/(102410241024), 2) “表空间使用大小(G)” from user_segments where segment_name = ‘CPS_PT_CUST_LB_RELA_TMPT’

查看索引空间大小

select segment_name as tablename,bytes/1024/1024/1024 “索引所占空间大小(G)” from user_segments where segment_type =‘INDEX’ and segment_name = ‘INDEX_CPS_PT_CUST_LB_RELA_TMPT’

查看不同空间大小

select segment_name,sum(bytes)/1024/1024/1024 from user_segments where segment_type =‘INDEX’ group by segment_name

oracle 查锁,解锁

select
v.SESSION_ID,
v.OS_USER_NAME,s.SERIAL#,
d.OWNER,d.OBJECT_NAME,v.LOCKED_MODE
from vlockedobjectv,dbaobjectsd,vlocked_object v, dba_objects d, vsession s
where d.OBJECT_ID=v.OBJECT_ID
and v.SESSION_ID=s.SID

–alter system kill session ‘1722,59613’;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!