How to Connect Oracle to VS Code

Galaxy Glossary

How can I connect my Oracle database to Visual Studio Code?

Connect Oracle Database to Visual Studio Code by installing the SQLTools or Oracle Developer Tools extension, creating a connection profile, and testing the link.

Sign up for the latest in SQL knowledge from the Galaxy Team!

Description

How do I add an Oracle connection in VS Code?

Open the Extensions panel, search for “SQLTools” or “Oracle Developer Tools for VS Code,” and click Install. Once installed, open the SQLTools sidebar, select Add New Connection, choose Oracle, and proceed to the profile form.

Which fields are mandatory in the profile form?

Fill in User, Password, Connect String (host:port/service_name or a TNS alias), and optionally Connection Name.VS Code stores the password securely in its secret store.

Can I use a TNS alias instead of host:port?

Yes. Ensure your local tnsnames.ora is reachable by the Oracle Instant Client. Enter the alias (for example ORCLPDB1) in the Connect String field.

What is the exact connection string syntax?

SQLTools accepts either EZConnect (host:port/service_name) or a TNS alias. Example: localhost:1521/ORCLPDB1.

How do I test the connection before saving?

Click Test Connection in the profile dialog.A green toast “Connected successfully” confirms connectivity; otherwise, review firewall rules, service name, and credentials.

How do I run a query after connecting?

Open a new .sql file, select the desired connection in the status bar, write your SQL, and press Ctrl+Enter (⌘+Enter on macOS).Results appear in an inline grid.

Sample e-commerce query

SELECT c.name, o.order_date, o.total_amount
FROM Customers c
JOIN Orders o ON o.customer_id = c.id
WHERE o.order_date > SYSDATE - 30;

Best practices for stable Oracle connections

Use the latest Basic or Full Instant Client, pin the version to match your database, and keep tnsnames.ora in $TNS_ADMIN. Set SQLNET.EXPIRE_TIME = 10 to avoid idle disconnects.

Common mistakes and quick fixes

Wrong driver path: VS Code cannot find libclntsh.dylib/so.Add the Instant Client folder to PATH or LD_LIBRARY_PATH.

Service name typo: ORCLPD1 instead of ORCLPDB1 causes ORA-12514. Copy the exact name from select service_name from v$services;.

.

Why How to Connect Oracle to VS Code is important

How to Connect Oracle to VS Code Example Usage


/* Find total spent by each customer in the last quarter */
SELECT   c.id,
         c.name,
         SUM(o.total_amount) AS quarterly_spend
FROM     Customers   c
JOIN     Orders      o ON o.customer_id = c.id
WHERE    o.order_date BETWEEN ADD_MONTHS(TRUNC(SYSDATE, 'Q'), -3)
                          AND TRUNC(SYSDATE, 'Q') - 1
GROUP BY c.id, c.name
ORDER BY quarterly_spend DESC;

How to Connect Oracle to VS Code Syntax


-- EZConnect syntax
CONNECT username/password@//host:port/service_name;

-- TNS alias syntax (requires tnsnames.ora)
CONNECT username/password@TNS_ALIAS;

-- VS Code (SQLTools) JSON profile
{
  "type": "oracle",
  "connectString": "localhost:1521/ORCLPDB1",
  "user": "ecom_user",
  "password": "StrongP@ssw0rd"
}

-- After connecting, query example tables
SELECT p.name, p.stock
FROM Products p
WHERE p.stock < 10;

Common Mistakes

Frequently Asked Questions (FAQs)

Do I need the full Oracle client to connect?

No. The lightweight Basic or Basic Lite Instant Client is sufficient for SQLTools and Oracle Developer Tools.

Can I connect with an SSH tunnel?

Yes. Create an SSH tunnel first (ssh -L 1521:dbhost:1521 user@bastion) and point the VS Code connection to localhost:1521.

Why do I get ORA-12514 after clicking Test Connection?

The service name is wrong or the listener isn’t registering it. Verify with lsnrctl status or query v$services.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo