使用 Oracle SQLcl 连接到专用 Exadata 基础结构上的自治 AI 数据库
提示:有关演示这些说明的“试用”替代方案,请从 Oracle Autonomous AI Database Dedicated Workshop 中的 Lab 2:Configure a Development System 中运行 Task 4:Connect to your Autonomous DB from Database Actions,SQLCL and SQL Plus 。
SQLcl (Oracle SQL Developer Command Line) 是 Oracle Database 的命令行界面。它允许以交互方式或批处理方式执行 SQL 和 PL/SQL。SQLcl 提供内嵌编辑、语句完成和命令撤回,以获得功能丰富的体验,同时还支持以前编写的 SQL*Plus 脚本。
为了能够将 SQLCl 连接到自治 AI 数据库,运行 SQLCl 的系统必须具有对自治 AI 数据库的网络访问权限。这可以通过以下任一方式实现:
-
通过配置开发系统以访问数据库。
-
通过使用 VPN 设置正确的网络路由(快速连接或 VPN 即服务)或任何 VCN 对等连接(如果计算主机位于其他 VCN 中)。
您可以将 SQLcl 版本 4.2 或更高版本用于自治 AI 数据库。从 oracle.com 下载 SQLcl。
SQLcl 可以使用 Oracle Call Interface (OCI) 或 JDBC 瘦连接来连接到自治 AI 数据库。
-
如果您使用 Oracle Call Interface (OCI),请首先按照 Prepare for ODBC and JDBC Oracle Call Interface (OCI) Connections 中的说明操作。
-
如果使用 JDBC Thin,请首先按照 Prepare for JDBC Thin Connections 中的说明操作。
SQLcl 与 Oracle Call Interface
要使用 Oracle Call Interface 进行连接,请使用 -oci 选项,提供 tnsnames.ora 文件中提供的数据库用户名、密码和数据库服务名称。例如:
sql -oci
SQLcl: Release 19.1 Production on Mon Jan 18 09:28:38 2021
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Username? (''?) sales_trans@atpc1_low
Password? (**********?) **************
Last Successful login time: Mon Jan 17 2019 15:29:19 -07:00
Connected to:
Oracle Database 19c EE Extreme Perf Release 19.0.0.0.0 - Production
Version 19.9.0.0.0
SQL>
使用 Oracle Call Interface 进行连接时,Oracle Wallet 对 SQLcl 是透明的。
具有 JDBC 瘦连接的 SQLcl
要使用 JDBC Thin 连接进行连接,请先配置 SQLcl 云配置,然后连接到自治 AI 数据库。
-
使用 /nolog 选项启动 SQLcl。
sql /nolog -
将 SQLcl 会话配置为使用 Oracle Wallet:
SQL> set cloudconfig directory/client_credentials.zip Wallet Password: ********** -
连接到自治 AI 数据库:
SQL> connect username@servicename password例如:
sql /nolog SQLcl: Release 19.1 Production on Mon Jan 18 09:28:38 2021 Copyright (c) 1982, 2021, Oracle. All rights reserved. SQL> set cloudconfig /home/atpc/wallet_ATPC.zip Operation is successfully completed. Operation is successfully completed. Using temp directory:/tmp/oracle_cloud_config3643858537577169472 SQL> connect admin@atpc_medium Password? (**********?) ************ Connected.
有关 tnsnames.ora 中指定的连接类型的更多信息,请参见 Predefined Database Service Names for Autonomous AI Databases 。
有关 SQLcl 的信息,请参阅 Oracle SQLcl 。