怎么用oracle命令连接远程数据库

怎么用oracle命令连接远程数据库,第1张

配置好相关的文件就可以,一般是tnsname.ora文件。

一般oracle10g的文件所在目录为:C:\oracle\product\10.2.0\db_1\network\ADMIN

其他版本的可在oracle目录下搜索tnsname.ora文件名进行修改。

ora =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl)

)

)

其中ora为本地实例名,xxx.xxx.xxx.xxx为远程IP地址,1521为端口号,orcl为远程数据库实例名,按照对方提供的内容进行修改即可。

1,非集群下 Windows环境下数据库

conn scott/123@127.0.0.1:1521/orcl

conn scott/123456@(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =

(PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)))(CONNECT_DATA =

(SERVER = DEDICATED)(SERVICE_NAME = orcl)))

Linux环境下数据库

conn scott/123@(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST

= 127.0.0.1)(PORT = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME =

orcl)))

2,集群下连接

conn scott/123@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE = yes)(FAILOVER = on)

(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(ADDRESS=

(PROTOCOL=TCP)(HOST=127.0.0.2)(PORT=1521)))(CONNECT_DATA=(SERVER=default)

(SERVICE_NAME=orcl)))

扩展资料

在命令行中登录oracle数据库:

sqlplus username/password  如:普通用户登录  sqlplus scott/tiger

sqlplus username/password as sysdba 如:sqlplus sys/admin as sysdba

sqlplus username/password@net_service_name 如: sqlplus scott/tiger@orcl

sqlplus username/password@//host:port/sid

参考资料:百度百科 - Oracle数据库


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6695040.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-26
下一篇 2023-03-26

发表评论

登录后才能评论

评论列表(0条)

保存