How to connect to Oracle database through computer's command prompt (cmd.exe)?
Suppose there is an Oracle database with the following information:
IP:192.168.0.1
SID:orcl
Port number: 1521
Username: testuser
Password: 123456
The service name configured in the local client is: server1
1. Connect to the database
sqlplus userName/userPassword@netServiceName through the service name
Example: sqlplus testuser/123456@server1
2. Connect to the database through IP:
sqlplus userName/userPassword@// (this double slash is optional) IP:port/SID (service_name should also be used for SID here)
例:sqlplus testuser/123456@//192.168.0.1:1521/orcl
The above are all connected through the network, and the oracle server needs to start the listener service. If you are connecting to a local database, the ip address can obviously be omitted. For sid, the ORACLE_SID parameter in the local registry HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraDb11g_home1 or the ORACLE_SID of the system parameter will be provided, so it can also be omitted.
At this time, you can log in by directly entering sqlplus username/password
Or sqlplus / as sysdba which is login with operating system authentication