PLSQL连接oracle数据库
方法一:instantclient_12_2
1、安装 instantclient_12_2 软件(免安装Oracle客户端)
2、PLSQL配置
打开PLSQL——》点取消,弹出PLSQL主界面——》菜单栏的tools——》属性preferences(首选项)——》连接
![](https://img2018.cnblogs.com/blog/620463/201905/620463-20190506124337036-646451141.png)
3、连接信息
![](https://img2018.cnblogs.com/blog/620463/201905/620463-20190506124400596-1228838188.png)
1)连接信息:可以是ip:1521/实例名 (例:192.168.0.1:1521/test)
2)也可以是network/admin目录下的tnsname.ora中配置的TNS别名
打开安装目录下—— instantclient_12_2\network\admin\tnsnames.ora文件
编辑:
# 本地Oracle数据库
TEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = DESKTOP-8BJ7RH7)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test)
)
)
# 在线Oracle数据库
TEST2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test)
)
)
需要另存为——》替换原文件
4、测试
登陆成功后 ——》新建sql ——》select * from dual;
执行看看,是否正常
方法二:Oracle
1、安装Oracle客户端
2、打开PLSQL——》点取消,弹出PLSQL主界面——》菜单栏的tools——》属性preferences(首选项)——》连接
![](https://img2018.cnblogs.com/blog/620463/201905/620463-20190506124453802-423265100.png)
3、连接信息
tnsnames.ora所在位置:
![](https://img2018.cnblogs.com/blog/620463/201905/620463-20190506124527618-701950390.png)