Show active sessions / running queries
Oracle
SELECT sid, serial#, username, status, sql_id, machine, program
FROM v$session
WHERE type = 'USER' AND status = 'ACTIVE';v$session gives the currently active sessions. For the full SQL text, join v$sql on sql_id.
PostgreSQL
SELECT pid, usename, state, wait_event_type, query
FROM pg_stat_activity
WHERE state <> 'idle';state = 'active' shows those running a query at that moment. Compute durations from backend_start / query_start.
MySQL
SELECT id, user, host, db, command, time, state, info
FROM information_schema.processlist
WHERE command <> 'Sleep';
-- Shortcut: SHOW FULL PROCESSLIST;On MySQL 8 / MariaDB, performance_schema.processlist holds fewer locks.
SQL Server
SELECT r.session_id, s.login_name, r.status, r.command,
r.cpu_time, r.total_elapsed_time, t.text AS sql_text
FROM sys.dm_exec_requests r
JOIN sys.dm_exec_sessions s ON r.session_id = s.session_id
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
WHERE s.is_user_process = 1;For a quick look: EXEC sp_who2 'active';
MongoDB
db.currentOp({ "active": true })To filter long-running operations: db.currentOp({ active: true, secs_running: { $gt: 5 } })
Redis
CLIENT LIST
# For a summary: INFO clientsBecause Redis is single-threaded, connected clients are listed instead of 'running queries'. For slow commands use SLOWLOG GET.