1. MySQL
-- 查看最大连接数
show variables like 'max_connections';
select @@max_connections;
-- select * from performance_schema.session_variables where VARIABLE_NAME in ('max_connections');
-- select * from performance_schema.global_variables where VARIABLE_NAME in ('max_connections');
-- select * from performance_schema.persisted_variables where VARIABLE_NAME in ('max_connections');
-- 查看当前连接数
show status like 'Threads_connected';
select count(1) from processlist;

2. Oracle
-- 允许最大进程数、连接数
select name,value from v$parameter where name in('processes' ,'sessions');
-- 当前进程数、连接数
select count(1) from v$session;
select count(1) from v$process;

附:Oracle连接数的调整
1. 查看最大连接数
您可以使用以下任意一个方法来查询:
show parameter processes;
或
select value from v$parameter where name ='processes';
2. 查看当前连接数
select count(*) from v$process;
3. 调整最大连接数
与共享池大小一样,建议您根据实际需求进行调整。
alter system set processes=1000 scope=spfile;
调整完毕后,请重启数据库服务以使更改生效。

