目前总结的语句,在查看数据的连接情况很有用,写完程序一边测试代码一边查看数据库连接的释放情况有助于分析优化出一个健壮的系统程序来。
1、查询oracle的连接数
select count(*) from v$session;
2、查询oracle的并发连接数
select count(*) from v$session where status='ACTIVE';
3、查看不同用户的连接数
select username,count(username) from v$session where username is not null group by username;
4、查看所有用户:
select * from all_users;
5、查看用户或角色系统权限(直接赋值给用户或角色的系统权限):
select * from dba_sys_privs;
select * from user_sys_privs;
6、查看角色(只能查看登陆用户拥有的角色)所包含的权限
select * from role_sys_privs;
7、查看用户对象权限:
select * from dba_tab_privs;
select * from all_tab_privs;
select * from user_tab_privs;
8、查看所有角色:
select * from dba_roles;
9、查看用户或角色所拥有的角色:
select * from dba_role_privs;
select * from user_role_privs;
10、查看哪些用户有sysdba或sysoper系统权限(查询时需要相应权限)
select * from V$PWFILE_USERS;
修改数据库允许的最大连接数:
alter system set processes = 300 scope = spfile;
查看游标数量
Select * from v$open_cursor Where user_name=''
查询数据库允许的最大连接数:
select value from v$parameter where name = 'processes';
或者:show parameter processes;
查询数据库允许的最大游标数:
select value from v$parameter where name = 'open_cursors'
查看oracle版本
select banner from sys.v_$version;
按降序显示用户"SYSTEM"为每个会话打开的游标数
select o.sid, osuser, machine, count(*) num_curs
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1.
Sql代码
1.select count(*) fromv$process
select count(*) from v$process where program=‘Oracle.EXE(SHAD)’; --当前的数据库连接数
2.
Sql代码
1.select value from v$parameter where name ='processes'
select value from v$parameter where name ='processes'--数据库允许的最大连接数
3.
Sql代码
1.alter system set processes = 300 scope =spfile;
alter system set processes = 300 scope = spfile;--修改最大连接数:
4.
Sql代码
1.shutdown immediate;
2.startup;
shutdown immediate;
startup;--重启数据库
5.
Sql代码
1.SELECT osuser, a.username,cpu_time/executions/1000000||'s',b.sql_text,machine
2.from v$session a, v$sqlareab
3.where a.sql_address =b.address order by cpu_time/executionsdesc;
SELECT osuser, a.username,cpu_time/executions/1000000||'s',b.sql_text,machine
from v$session a, v$sqlarea b
where a.sql_address =b.address order by cpu_time/executionsdesc;
--查看当前有哪些用户正在使用数据
6.
Sql代码
1.select count(*) fromv$session
select count(*) from v$session
7.
Sql代码
1.select count(*) from v$session wherestatus='ACTIVE'
select count(*) from v$session where status='ACTIVE' --并发连接数
8.
Sql代码
1.show parameterprocesses
show parameter processes