欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

oracle如何查看当前有哪些用户连接到数据库

程序员文章站 2023-04-08 08:19:40
可以执行以下语句:select username,serial#, sid from v$session; 查询用户会话alter system kill session 'serial#, sid '; 删除相关用户会话 建议以后台登陆删除用户会话1、查询oracle的连接数select coun ......

可以执行以下语句:
select username,serial#, sid from v$session; ---查询用户会话
alter system kill session 'serial#, sid ';---删除相关用户会话

建议以后台登陆删除用户会话
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 from v$open_cursor o, v$session s where user_name = 'system' and o.sid=s.sid group by o.sid, osuser, machine order by num_curs desc;

以上转载自 https://www.cnblogs.com/caogang/p/4546072.html

保留两位小数以gb为单位显示数据文件大小
select round(sum(bytes)/1024/1024/1024,2)||'gb' from dba_data_files;

以mb为单位表空间分组显示数据文件大小
select tablespace_name,sum(bytes)/1024/1024 as mb from dba_data_files
group by tablespace_name;

显示数据库中临时文件的大小
select sum(bytes)/1024/1024/1024 as gb from dba_temp_files;

显示数据库中日志文件的大小
select sum(bytes)/1024/1024/1024 as gb from v$log;

显示数据库中数据文件、临时文件、日志文件的总大小
select sum(gb) as gb
from(
select sum(bytes)/1024/1024/1024 as gb
from dba_data_files
union all
select sum(bytes)/1024/1024/1024
from dba_temp_files
union all
select sum(bytes)/1024/1024/1024
from v$log
);

select round(sum(bytes) / 1024 / 1024, 2) "used(m)"
from dba_segments
group by owner, tablespace_name
order by sum(bytes) desc;

--1、查看所有表空间及表空间大小:
select tablespace_name ,sum(bytes) / 1024 / 1024 as mb from dba_data_files group by tablespace_name;

--2、查看所有表空间对应的数据文件:
select tablespace_name,file_name from dba_data_files;

--3、修改数据文件大小:
alter database datafile 'h:\oracle\product\10.1.0\oradata\oracle\users01.dbf' resize 10240m;

select file_name,bytes/1024/1024 mb from dba_data_files;