sql - 我如何连接到 ODBC Oracle 数据库?

标签 sql database oracle odbc

我有关于连接的信息,如用户名、密码、主机、端口、SID,我知道这是一个 oracle 数据库,但我不知道如何连接。我在 lubuntu 18.04 上。

最佳答案

您可以使用 sqlplus 连接到远程 Oracle 数据库服务器并执行查询。 为此,首先按照https://help.ubuntu.com/community/Oracle%20Instant%20Client中写的信息安装sqlplus。页。您基本上会执行以下命令。

首先从这里下载 .rpm 文件:https://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html

对于 x64 版本

https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

对于 x86 版本

https://www.oracle.com/technetwork/topics/linuxsoft-082809.html

然后安装alien将.rpm文件转换成.deb包并自动安装包。

sudo apt update

sudo apt install alien

下载到目录后,执行以下命令; 当前可用于 Linux 的最新版本是 18.3。因此,例如,rpm 文件可以如下所示。

假设您在主目录中并将文件下载到该位置。

sudo alien -i /home/yourusername/oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
sudo alien -i /home/yourusername/oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm
sudo alien -i /home/yourusername/oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm

(安装的最多的是3个)

然后如下测试你的连接

sqlplus username/password@//dbhostname:port/SID
sqlplus64 username/password@//dbhostname:port/SID (If you installed sqlplus x64 version)

此外,上面给出的 Ubuntu 文档页面还介绍了遇到以下任何问题时的问题解决方案。

If you execute sqlplus and get "sqlplus: command not found", see the section below about adding the ORACLE_HOME variable.

If sqlplus complains of a missing libsqlplus.so file, follow the steps in the section "Integrate Oracle Libraries" below.

If sqlplus complains of a missing libaio.so.1 file, run

sudo apt install libaio1

or, if you're installing the 32 bit instant client on 64 bit,

sudo apt install libaio1:i386

完成所有这些操作后,您还可以安装“rlwrap”并与 sqlplus 集成以带来自动完成和体面的输入历史记录。

sudo apt install rlwrap

rlwrap sqlplus username/password@//dbhostname:port/SID

或者您可以定义一个别名。

alias sqlpl='rlwrap sqlplus username/password@//dbhostname:port/SID'

sqlpl

最后,如果你安装了 x64 版本,不要忘记将 sqlplus 替换为 sqlplus64。

关于sql - 我如何连接到 ODBC Oracle 数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53307641/

相关文章:

mysql - 在文件名sql表达式上将字符与日期分开

sql - 使用 Visual Studio 2008 部署 SQL 项目时出错

mysql - 如何从现有数据库导入到 opencart 数据库

mysql - Phpmyadmin 出现错误

oracle - Aqua Data Studio 中声明变量和执行过程的语法?

.net - ODP.NET是否需要安装Oracle客户端

c# - 我应该学习哪些概念来实现这一点?

sql - 改变列(使用 + where)

java - 从 SQL 表中进行统计

sql - 查询的开始和结束时间