

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

# STL\$1CONNECTION\$1LOG
<a name="r_STL_CONNECTION_LOG"></a>

记录身份验证尝试以及连接与断开连接。

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

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

## 表列
<a name="r_STL_CONNECTION_LOG-table-columns2"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/dg/r_STL_CONNECTION_LOG.html)

## 示例查询
<a name="r_STL_CONNECTION_LOG-sample-queries2"></a>

要查看打开连接的详细信息，请运行以下查询。

```
select recordtime, username, dbname, remotehost, remoteport
from stl_connection_log
where event = 'initiating session'
and pid not in 
(select pid from stl_connection_log
where event = 'disconnecting session')
order by 1 desc;

recordtime          | username    | dbname     | remotehost    | remoteport                      
--------------------+-------------+------------+---------------+------------
2014-11-06 20:30:06 | rdsdb       | dev        | [local]       |                            
2014-11-06 20:29:37 | test001     | test       | 10.49.42.138  | 11111                           
2014-11-05 20:30:29 | rdsdb       | dev        | 10.49.42.138  | 33333                                                 
2014-11-05 20:28:35 | rdsdb       | dev        | [local]       |  
(4 rows)
```

以下示例反映了一次失败的身份验证尝试和一次成功的连接与断开连接。

```
select event, recordtime, remotehost, username
from stl_connection_log order by recordtime;            

            event      |         recordtime        |  remotehost  | username                      
-----------------------+---------------------------+--------------+---------
authentication failure | 2012-10-25 14:41:56.96391 | 10.49.42.138 | john                                              
authenticated          | 2012-10-25 14:42:10.87613 | 10.49.42.138 | john                                              
initiating session     | 2012-10-25 14:42:10.87638 | 10.49.42.138 | john                                              
disconnecting session  | 2012-10-25 14:42:19.95992 | 10.49.42.138 | john                                              
(4 rows)
```

以下示例显示了 ODBC 驱动程序的版本、客户端计算机上的操作系统以及用于连接到 Amazon Redshift 集群的插件。在此示例中，使用的插件用于使用登录名和密码进行标准 ODBC 驱动程序身份验证。

```
select driver_version, os_version, plugin_name from stl_connection_log;
                
driver_version                          |  os_version                       | plugin_name
----------------------------------------+-----------------------------------+--------------------
Amazon Redshift ODBC Driver 1.4.15.0001 | Darwin 18.7.0 x86_64              | none
Amazon Redshift ODBC Driver 1.4.15.0001 | Linux 4.15.0-101-generic x86_64   | none
```

以下示例显示了客户端计算机上的操作系统版本、驱动程序版本和协议版本。

```
select os_version, driver_version, protocol_version from stl_connection_log;
                
os_version                      |  driver_version              | protocol_version
--------------------------------+------------------------------+--------------------
Linux 4.15.0-101-generic x86_64 | Redshift JDBC Driver 2.0.0.0 | 2
Linux 4.15.0-101-generic x86_64 | Redshift JDBC Driver 2.0.0.0 | 2 
Linux 4.15.0-101-generic x86_64 | Redshift JDBC Driver 2.0.0.0 | 2
```