获取有关已连接数据库上的附件的信息
有关数据库连接的信息
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)
结果:
更具体的例子
有关已连接客户端的信息。
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