(show_sessions.sql)
set serveroutput on declare cursor cur_vsession is select machine, program from v$session; val_vsession cur_vsession%ROWTYPE; begin open cur_vsession; loop fetch cur_vsession into val_vsession; exit when cur_vsession%NOTFOUND; dbms_output.put('マシン名:' || val_vsession.machine || chr(9)); dbms_output.put_line('プログラム名:' || val_vsession.program); end loop; close cur_vsession; end; / quit
使ってみる
>sqlplus **/**@//192.168.132.135:1521/xe @./show_sessions.sql SQL*Plus: Release 11.2.0.1.0 Production on 土 5月 17 22:26:50 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production に接続されました。 マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (PMON) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (PSP0) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (VKTM) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (GEN0) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (DIAG) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (DBRM) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (DIA0) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (MMAN) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (DBW0) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (LGWR) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (CKPT) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (SMON) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (RECO) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (MMON) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (MMNL) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (Q000) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (VKRM) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (QMNC) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (CJQ0) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (Q001) マシン名:WORKGROUP\BROS プログラム名:sqlplus.exe マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (W000) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (W001) マシン名:localhost.localdomain プログラム名:oracle@localhost.localdomain (SMCO) マシン名:bros プログラム名:SQL Developer マシン名:localhost.localdomain プログラム名:sqlplus@localhost.localdomain (TNS V1-V3) PL/SQLプロシージャが正常に完了しました。 Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Productionとの接続が切断されました。