如何用cmd命令连接oracle数据库

2024-11-04 09:09:08
推荐回答(4个)
回答1:

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数据库

回答2:

输入sqlplus,然后提示输入用户名,直接输入user/password@database就可以了,然后出来sql>,就可以输入各种语句了

回答3:

在系统命令行输入sqlplus /nologconn sys / as sysdbashutdow immediate;startup;如果在linux下可用dbstart,前提是你配置好了dbstart脚本

回答4:

sqlplus / as sysdba
用户名和密码是略过的,因为默认使用操作系统认证