Show running processes in Oracle DB
Oracle tip: Script แสดง query ที่ทำงานอยู่บน Oracle database (คล้ายๆ คำสั่ง show processlist บน MySQL)
show_processlist.sh
#!/bin/bash
sqlplus -s /nolog << EOF
CONNECT / as sysdba
whenever sqlerror exit sql.sqlcode;
set line 200;
set pages 200;
col SPID format a10;
col USERNAME format a15;
col ID format a10;
col STATUS format a10;
col "Last Activity" format 9999999999;
col sql_text format a70;
select p.SPID, s.username, s.sid || ',' || s.serial# "ID", s.status, s.last_call_et "Last Activity", b.sql_text from v\$session s, v\$sqlarea b, v\$process p where s.username is not null and p.addr = s.paddr and s.sql_address=b.address;
EOF
ตัวอย่างผลลัพธ์