

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# STL\_USERLOG
<a name="r_STL_USERLOG"></a>

记录数据库用户的以下更改的详细信息。
+ 创建用户
+ 删除用户
+ 更改用户（重命名）
+ 更改用户（更改属性）

STL\_USERLOG 仅对超级用户可见。有关更多信息，请参阅 [系统表和视图中的数据可见性](cm_chap_system-tables.md#c_visibility-of-data)。

此表中的部分或全部数据也可以在 SYS 监控视图 [SYS\_USERLOG](SYS_USERLOG.md) 中找到。SYS 监控视图中的数据经过格式化处理，便于使用和理解。我们建议您使用 SYS 监控视图进行查询。

## 表列
<a name="r_STL_USERLOG-table-columns"></a>


| 列名称  | 数据类型  | 描述  | 
| --- | --- | --- | 
| userid | integer | 受更改影响的用户的 ID。 | 
| username | character(50) | 受更改影响的用户的用户名称。 | 
| oldusername | character(50) | 对于重命名操作，这是原始用户名称。对于任何其他操作，此字段为空。 | 
| 操作 | character(10) | 发生的操作。有效值：[See the AWS documentation website for more details](http://docs.amazonaws.cn/redshift/latest/dg/r_STL_USERLOG.html)  | 
| usecreatedb | integer | 如果为 true (1)，则表示用户具有创建数据库的权限。 | 
| usesuper | integer | 如果为 true (1)，则表示用户为超级用户。 | 
| usecatupd | integer | 如果为 true (1)，则表示用户可更新系统目录。 | 
| valuntil | timestamp | 密码到期日期。 | 
| pid | integer | 进程 ID。 | 
| xid | bigint | 事务 ID。 | 
| recordtime | timestamp | 查询开始的时间（采用 UTC 表示）。 | 

## 示例查询
<a name="r_STL_USERLOG-sample-queries"></a>

以下示例执行四种用户操作，然后查询 STL\_USERLOG 视图。

```
create user userlog1 password 'Userlog1';
alter user userlog1 createdb createuser;
alter user userlog1 rename  to userlog2;
drop user userlog2;

select userid, username, oldusername, action, usecreatedb, usesuper from stl_userlog order by recordtime desc;
```

```
 userid |  username | oldusername |  action | usecreatedb | usesuper
--------+-----------+-------------+---------+-------------+----------
    108 | userlog2  |             | drop    |           1 |   1
    108 | userlog2  | userlog1    | rename  |           1 |   1
    108 | userlog1  |             | alter   |           1 |   1
    108 | userlog1  |             | create  |           0 |   0
 (4 rows)
```