The Oracle database connection command is typically executed using SQL*Plus, a command-line tool provided by Oracle to interact with the database. The basic syntax for connecting to an Oracle database is:
sqlplus username/password@[//]host[:port][/service_name]
username: The database user account (e.g., scott).password: The password for the user (e.g., tiger).host: The hostname or IP address of the database server (e.g., localhost or 192.168.1.100).port: The port number where the Oracle listener is running (default is 1521).service_name: The Oracle service name (or SID for older versions).Connecting to a local Oracle database (default port 1521, service name ORCL):
sqlplus scott/tiger@//localhost:1521/ORCL
or (older SID-based connection):
sqlplus scott/tiger@//localhost:1521:ORCL
Connecting without specifying the host (for local databases):
sqlplus scott/tiger
(This assumes the database is running locally and the environment is properly configured.)
Using TNS (via tnsnames.ora configuration):
If you have a TNS alias defined in tnsnames.ora, you can connect like this:
sqlplus scott/tiger@ORCL_TNS
(Where ORCL_TNS is the alias defined in the TNS configuration file.)
If you're using an Oracle database hosted on Tencent Cloud Database (TencentDB for Oracle), the connection command remains similar, but you must ensure:
Example for Tencent Cloud Oracle:
sqlplus admin/YourPassword@//your-database-ip:1521/ORCL
For secure connections, consider using SSL/TLS or VPN if the database is in a private network. Tencent Cloud also provides Database Connection Tools and PrivateLink for secure access.
If you prefer a GUI tool, SQL Developer (Oracle's official client) or Tencent Cloud Database Console can also be used to manage connections.