数据库连接数查询
select count() from v
p
r
o
c
e
s
s
;
−
−
当
前
的
数
据
库
连
接
数
s
e
l
e
c
t
c
o
u
n
t
(
∗
)
f
r
o
m
v
process ; --当前的数据库连接数 select count(*) from v
process;−−当前的数据库连接数selectcount(∗)fromvsession ; --当前的session连接数
select count() from v
s
e
s
s
i
o
n
w
h
e
r
e
s
t
a
t
u
s
=
′
A
C
T
I
V
E
′
;
−
−
并
发
连
接
数
s
e
l
e
c
t
v
a
l
u
e
f
r
o
m
v
session where status='ACTIVE'; --并发连接数 select value from v
sessionwherestatus=′ACTIVE′; −−并发连接数selectvaluefromvparameter where name =‘processes’; --数据库允许的最大连接数
select username,count(username) from v$session where username is not null group by username ; --查询各个用户名连接数
select object_name,machine,s.sid,s.serial# from v l o c k e d o b j e c t l , d b a o b j e c t s o , v locked_object l,dba_objects o ,v lockedobjectl,dbaobjectso,vsession s where l.object_id = o.object_id and l.session_id=s.sid;
alter system kill session ‘sid, serial#’; --(978, 11145)
查询表空间总量
SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size
FROM dba_tablespaces t, dba_data_files d
WHERE t.tablespace_name = d.tablespace_name
GROUP BY t.tablespace_name;
查询表空间剩余
SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name
FROM dba_free_space
GROUP BY tablespace_name;
清空回收站
purge recyclebin