SYS_SESSION_HISTORY - Amazon Redshift

SYS_SESSION_HISTORY

使用 SYS_SESSION_HISTORY 查看有关当前活动的会话和会话历史记录的信息。

SYS_SESSION_HISTORY 对所有用户可见。超级用户可以查看所有行;普通用户只能查看其自己的数据。有关更多信息,请参阅 系统表和视图中的数据可见性

表列

列名称 数据类型 描述
user_id char(50) 生成该条目的用户的标识符。
session_id 整数 与语句关联的会话的 ID。
database_name char(50) 数据库的名称。
status char 会话的状态。可能的值为 activetimed outclosed
session_timeout 整数 超时前会话保持非活动状态或空闲状态的最长时间(秒)。0 表示未设置超时。
start_time 时间戳 建立连接的时间戳。
end_time 时间戳 停止连接的时间戳。

示例

以下是 SYS_SESSION_HISTORY 的示例输出。

select * from sys_session_history; user_id | session_id | database_name | status | session_timeout | start_time | end_time ---------+------------+------------------+--------+-----------------+----------------------------+---------------------------- 1 | 1073971370 | dev | closed | 0 | 2023-07-17 15:50:12.030104 | 2023-07-17 15:50:12.123218 1 | 1073979694 | dev | closed | 0 | 2023-07-17 15:50:24.117947 | 2023-07-17 15:50:24.131859 1 | 1073873049 | dev | closed | 0 | 2023-07-17 15:49:29.067398 | 2023-07-17 15:49:29.070294 1 | 1073873086 | database18127a4a | closed | 0 | 2023-07-17 15:49:29.119018 | 2023-07-17 15:49:29.125925 1 | 1073832112 | dev | closed | 0 | 2023-07-17 15:49:29.164688 | 2023-07-17 15:49:29.179631 1 | 1073987697 | dev | closed | 0 | 2023-07-17 15:49:29.26749 | 2023-07-17 15:49:29.273034 1 | 1073922429 | dev | closed | 0 | 2023-07-17 15:49:33.35315 | 2023-07-17 15:49:33.367499 1 | 1073766783 | dev | closed | 0 | 2023-07-17 15:49:45.38237 | 2023-07-17 15:49:45.396902 1 | 1073807506 | dev | active | 0 | 2023-07-17 15:51:48 |