獲取有關已連線資料庫上的附件的資訊

有關資料庫連線的資訊

SELECT
       a.mon$attachment_id as Attachment_ID,
       a.mon$server_pid as Server_PID, 
       case a.mon$state 
          when 1 then 'active'
          when 0 then 'idle'
       end as State, 
       a.mon$attachment_name as Database_Name, 
       a.mon$user as User_Name, 
       a.mon$role as Role_Name, 
       a.mon$remote_protocol as Remote_Protocol, 
       a.mon$remote_address as  Remote_Address, 
       a.mon$remote_pid as Remote_PID, 
       cs.rdb$character_set_name as Connection_Character_Set, 
       a.mon$timestamp as Established_At,
       case a.mon$garbage_collection 
          when 1 then 'allowed'
          when 0 then 'not allowed'
       end as Garbage_Collection, 
       a.mon$remote_process as Remote_Process, 
       a.mon$stat_id as Statistics_ID
    FROM
       mon$attachments a, rdb$character_sets cs
    where 
       (a.mon$character_set_id = cs.rdb$character_set_id)

結果:

StackOverflow 文件

更具體的例子

有關已連線客戶端的資訊。

SELECT
   a.mon$remote_protocol as Remote_Protocol,
   a.mon$remote_address as  Remote_Address,
   a.mon$remote_pid as Remote_PID,
   a.mon$timestamp as Established_At,
   a.mon$remote_process as Remote_Process
FROM
   mon$attachments a

檢索當前載入 CPU 的所有伺服器程序的 PID(對於經典伺服器體系結構感興趣)

SELECT
   MON$SERVER_PID
FROM
   MON$ATTACHMENTS
WHERE
   MON$STATE = 1

檢索有關已連線使用者,工作站和客戶端應用程式的資訊

SELECT
   mon$attachment_name as Database_Name,
   mon$user as User_Name,
   mon$role as Role_Name,
   mon$remote_process as Client_Application,
   mon$remote_address as Client_IP,
   mon$remote_pid as Client_Application_PID
FROM
   mon$attachments

參考: