> ## Content Index
> Fetch the complete content index at: https://www.ggorantala.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# Oracle SID vs Service Name vs PDB Name in Connection Strings
- URL: https://www.ggorantala.dev/oracle-sid-vs-service-name/
- Published: 2026-12-01T19:13:33.000Z
- Updated: 2026-12-01T19:13:33.000Z
- Description: SID, service name, PDB name or TNS alias? Which one goes in your JDBC URL, tnsnames.ora or Python DSN, why FREE and FREEPDB1 are not interchangeable, and the exact error each mix-up gives you (ORA-12505, ORA-12514, ORA-12154).
- Author: Gopi Gorantala
- Tags: service-name, oracle-sid, oracle-pdb, tnsnames, oracle-jdbc, oracle-net, oracle-database

You've probably already tried it. `FREE` in the URL, then `FREEPDB1`, then a colon instead of a slash, then the slash back with `FREE` again, until one combination stopped throwing and you moved on. Everyone does this the first week they point an app at Oracle. The trouble is that one of those "working" combinations is wrong, and it doesn't tell you so until a table goes missing two days later.

So here's the whole SID vs service name question, plus the two names people throw into the same bucket: the PDB name and the TNS alias. Short version first. **Connect with a service name.** For an app talking to a pluggable database, that's the PDB's service (often the PDB name itself, ideally a service you created for the app). The SID names an instance, not a database you should be connecting your app to, and in a multitenant database it points you at the root container. The TNS alias is a nickname your client looks up locally; the database never sees it.

## Four names, one database

Here's what each one names, in plain words:

- **SID** (system identifier): the name of an instance, the running set of memory and background processes on one host. It's `ORACLE_SID` on the server and the `INSTANCE_NAME` parameter. On Oracle Database Free it's `FREE`; on XE it's `XE`. On RAC, each node has its own (`ORCL1`, `ORCL2`).
- **Service name**: a logical name the instance registers with the listener so clients can ask for "the invoices database" without caring which instance serves it. One database can offer many services, and one service can run on many instances.
- **PDB name**: the name of a pluggable database inside a container database (CDB). Not a connect identifier by itself. But creating a PDB automatically creates a default service with the same name, which is why `FREEPDB1` works after the slash.
- **TNS alias** (net service name): a key in your client's `tnsnames.ora`, like `INVOICES`, that expands into a full connect descriptor on your machine. The listener never hears the word `INVOICES`.

The [Net Services Administrator's Guide](https://docs.oracle.com/en/database/oracle/oracle-database/26/netag/understanding-database-services.html?ref=ggorantala.dev) puts the service model in one sentence I keep coming back to: a service can identify several instances, and an instance can belong to several services, so the listener sits in the middle and routes you. A SID skips that routing. You're saying "give me this exact instance on this host."

## The cheat sheet table

|                      | SID                                  | Service name                                                                     | PDB name                                                    | TNS alias                      |
| -------------------- | ------------------------------------ | -------------------------------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------ |
| What it names        | One instance                         | A logical service, registered with the listener                                  | A pluggable database                                        | An entry in a client-side file |
| Where it's defined   | ORACLE\_SID, INSTANCE\_NAME          | Default from DB\_UNIQUE\_NAME.DB\_DOMAIN; extra ones via DBMS\_SERVICE or srvctl | CREATE PLUGGABLE DATABASE                                   | tnsnames.ora on the client     |
| Who reads it         | Listener                             | Listener                                                                         | Nobody directly; its default service is what you connect to | Your client's naming layer     |
| JDBC thin syntax     | @host:port:SID                       | @//host:port/service                                                             | @//host:port/pdbname (its default service)                  | @ALIAS with TNS\_ADMIN set     |
| tnsnames.ora key     | (SID=...)                            | (SERVICE\_NAME=...)                                                              | (SERVICE\_NAME=pdbname)                                     | the left-hand side             |
| Reaches a PDB?       | No, lands in the root or an instance | Yes                                                                              | Yes, via its default service                                | Whatever the alias expands to  |
| Typical mix-up error | ORA-12505                            | ORA-12514                                                                        | ORA-12505 if sent as a SID                                  | ORA-12154                      |
| First check          | lsnrctl status instance list         | lsnrctl services                                                                 | SELECT name, open\_mode FROM v$pdbs;                        | tnsping ALIAS                  |

## Where the differences bite

### The colon vs the slash

In a JDBC thin URL, punctuation decides which field your name lands in. This is the one-character difference behind most ORA-12505 reports:

```properties
# name goes into (SID=...) : instance lookup
spring.datasource.url=jdbc:oracle:thin:@db-invoices:1521:FREEPDB1
# name goes into (SERVICE_NAME=...) : service lookup
spring.datasource.url=jdbc:oracle:thin:@//db-invoices:1521/FREEPDB1

```

The first one asks the listener for an instance called `FREEPDB1`. There isn't one; a PDB isn't an instance. You get:

```log
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

```

That's the 19c-era wording; 23ai/26ai clients print `ORA-12505: Cannot connect to database. SID ... is not registered with the listener at host ... port ...`, per [Oracle's error help page](https://docs.oracle.com/en/error-help/db/ora-12505/?ref=ggorantala.dev). The second URL asks for a service and works. I wrote the full diagnosis for that one in [ORA-12505: listener does not know of SID](https://ggorantala.dev/ora-12505-listener-does-not-know-sid/?ref=ggorantala.dev).

One aside. Oracle's own [Free quick start page](https://www.oracle.com/uk/database/free/get-started/?ref=ggorantala.dev) shows `jdbc:oracle:thin:@localhost:1521/FREEPDB1`, without the `//`, and current drivers take it. I still write the slashes, because older drivers want them and the [Easy Connect syntax reference](https://docs.oracle.com/en/database/oracle/oracle-database/26/netag/understanding-easy-connect-naming-method.html?ref=ggorantala.dev) lists `//` as required for URL and JDBC connections.

### The same names in tnsnames.ora

The descriptor shows the difference without punctuation tricks:

```ini
INVOICES =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db-invoices)(PORT = 1521))
    (CONNECT_DATA = (SERVICE_NAME = invoices_app)))

INVOICES_BY_SID =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db-invoices)(PORT = 1521))
    (CONNECT_DATA = (SID = FREE)))

```

`INVOICES` is the alias. `invoices_app` is the service. `FREE` is the SID. Three different names, three different jobs, all in eight lines. If the client can't find `INVOICES` in the file it actually read, it fails before any network traffic with ORA-12154 ([which tnsnames.ora it read is its own story](https://ggorantala.dev/ora-12154-could-not-resolve-connect-identifier/?ref=ggorantala.dev)).

### Python, SQL\*Plus and SQL Developer

python-oracledb makes you pick by keyword, which is honest of it:

```python
import oracledb

# service name: what you want
dsn = oracledb.makedsn("db-invoices", 1521, service_name="FREEPDB1")
# SID: instance lookup, lands in the root on Free
dsn_sid = oracledb.makedsn("db-invoices", 1521, sid="FREE")

```

SQL\*Plus and SQLcl take Easy Connect, which has no SID slot at all: `sqlplus archive_app@//db-invoices:1521/FREEPDB1`. The syntax does allow an instance name after the service (`//host:port/service/instance_name`), but that's for pinning a RAC session to one instance, not for replacing the service. SQL Developer's Basic connection type has two radio buttons, "SID" and "Service name", and picking the wrong one with `FREEPDB1` in the box is the GUI version of the colon mistake.

### Where the default service name comes from

The [SERVICE\_NAMES reference for 26ai](https://docs.oracle.com/en/database/oracle/oracle-database/26/refrn/SERVICE%5FNAMES.html?ref=ggorantala.dev) gives the default as `DB_UNIQUE_NAME.DB_DOMAIN`. If `DB_DOMAIN` is set to `corp.example.com`, your default service is `invoices.corp.example.com`, and a URL ending `/invoices` gets ORA-12514\. That one catches people moving from a dev box with no domain to a production database with one. The same page says the parameter itself has been deprecated since 19c, isn't supported for HA features like FAN, and that services should be managed with `srvctl`, `gdsctl` or `DBMS_SERVICE` instead. Worth knowing before you add a service by editing `SERVICE_NAMES`.

## Try all four against one container

I couldn't run Oracle in this session's workspace: its network refused both Docker Hub and `container-registry.oracle.com`, so there's no lab output below. What follows is the exact sequence, with the result each step should give according to Oracle's docs and the behaviour covered in the linked articles. Run it on your laptop, never against a shared database.

1. Start a disposable Free database. `gvenzl/oracle-free` is a community image; pin whatever tag you use.

```bash
docker run -d --name sidlab -p 1521:1521 \
  -e ORACLE_PASSWORD=LabOnly_2026 \
  -e APP_USER=archive_app -e APP_USER_PASSWORD=LabOnly_2026 \
  gvenzl/oracle-free:23-slim-faststart
docker logs -f sidlab   # wait for DATABASE IS READY TO USE!

```

1. Ask the database what each name actually is. Run this as `archive_app` through the PDB service:

```sql
SELECT sys_context('USERENV', 'INSTANCE_NAME') AS sid,
       sys_context('USERENV', 'SERVICE_NAME')  AS service,
       sys_context('USERENV', 'CON_NAME')      AS container,
       sys_context('USERENV', 'DB_NAME')       AS db_name
FROM dual;

```

```bash
docker exec -i sidlab sqlplus -s archive_app/LabOnly_2026@//localhost:1521/FREEPDB1 <<'SQL'
SELECT sys_context('USERENV','INSTANCE_NAME') sid, sys_context('USERENV','SERVICE_NAME') service, sys_context('USERENV','CON_NAME') container FROM dual;
SQL

```

Expected: SID `FREE`, service `FREEPDB1`, container `FREEPDB1`. Same instance, different service. That one row is most of this article.

1. Now the four connect strings, back to back. `-L` makes SQL\*Plus give up after one failed attempt instead of prompting again:

```bash
for cs in "//localhost:1521/FREEPDB1" \
          "//localhost:1521/FREE" \
          "//localhost:1521/INVOICES" \
          "INVOICES"; do
  echo "== $cs"
  docker exec -i sidlab sqlplus -s -L archive_app/LabOnly_2026@"$cs" <<'SQL'
SELECT sys_context('USERENV','CON_NAME') FROM dual;
SQL
done

```

What each should do:

- `/FREEPDB1` connects and prints `FREEPDB1`.
- `/FREE` reaches the listener fine, because `FREE` is also the root container's default service. You land in `CDB$ROOT`, where `archive_app` doesn't exist, so you get ORA-01017\. Not a network error. The name half-worked.
- `/INVOICES` gets ORA-12514: the listener answered and has no such service.
- Bare `INVOICES` gets ORA-12154: there's no `tnsnames.ora` in the container defining that alias, so the client never left the building.
- The colon form needs a JDBC client, so for that one use the `Lab.java` from the [ORA-12505 write-up](https://ggorantala.dev/ora-12505-listener-does-not-know-sid/?ref=ggorantala.dev) with `@localhost:1521:FREEPDB1`. Expected: ORA-12505.
- Teardown: `docker rm -f sidlab`. The slim image keeps data inside the container unless you mounted a volume; if you did, remove it too, or the next `docker run` will reuse a database with this lab's passwords.

## When the wrong name half-works

The loud mistakes are fine. ORA-12505 and ORA-12514 stop you at connect time and the message names the thing it couldn't find. The quiet one is the SID used as a service, or the CDB service used for an app.

On Free, `FREE` is both the SID and a real service, the root container's. So `@//host:1521/FREE` connects. If you're connecting as `SYSTEM`, it even lets you run queries, because `SYSTEM` is a common user that exists in the root. Then you create your tables, and they're in `CDB$ROOT`. A week later someone connects the app through `FREEPDB1` and gets ORA-00942 for a table they can see in SQL Developer, because SQL Developer is still on the root. Or a `CREATE USER archive_app` in the root fails with ORA-65096, and someone "fixes" it with an underscore parameter they found on a forum. Both are downstream of one wrong word in a URL. [CDB vs PDB](https://ggorantala.dev/oracle-cdb-vs-pdb-errors/?ref=ggorantala.dev) covers that whole family.

The RAC version costs more. A SID URL pins every connection to one node. It works, right up until that node goes down for patching, and the pool can't fail over because you never asked for a service that lives anywhere else. Nothing in the error tells you the URL was the reason the failover didn't happen.

What I checked for this piece: the 26ai Net Services Administrator's Guide sections on database services and Easy Connect, the `SERVICE_NAMES` page in the 26ai Reference, the 23ai Multitenant guide's PDB service rules, Oracle's error help pages for ORA-12505 and ORA-12514, and Oracle's Free quick start. The thing I had wrong going in was assuming `FREE` would fail outright as a service name. It doesn't. That's exactly what makes it dangerous.

## Which name did this connection really use?

When something's off in production and you don't trust the config, ask the session. These are the queries I'd run from the app's own connection, or from a DBA session for everybody:

```sql
-- from the app's own session: which instance, service and container am I in?
SELECT sys_context('USERENV', 'INSTANCE_NAME') AS sid,
       sys_context('USERENV', 'SERVICE_NAME')  AS service,
       sys_context('USERENV', 'CON_NAME')      AS container
FROM dual;

-- needs SELECT on v$session (a DBA or a monitoring role): who came in through which service
SELECT username, service_name, machine, COUNT(*) AS sessions
FROM   v$session
WHERE  type = 'USER'
GROUP  BY username, service_name, machine
ORDER  BY sessions DESC;

-- needs access to v$active_services: services the instance is offering right now
SELECT name, con_id FROM v$active_services ORDER BY con_id, name;

```

On the database host, `lsnrctl services` lists every service the listener knows and the instance behind each (`Service "freepdb1" has 1 instance(s). Instance "FREE", status READY`). That line literally shows the service-to-SID mapping. A full walkthrough of that output is in [reading lsnrctl status and services](https://ggorantala.dev/lsnrctl-status-services-explained/?ref=ggorantala.dev).

If an app account shows up under the CDB's service in that `v$session` query, you've found a quiet one. Change its URL to the PDB's service before anyone creates objects through it.

And the design I'd actually ship: don't connect apps to the PDB's default service either. The [Multitenant guide](https://docs.oracle.com/en/database/oracle/oracle-database/23/multi/administering-pdbs-with-sql-plus.html?ref=ggorantala.dev) says every PDB gets a default service named after it, and that you can create your own with `DBMS_SERVICE` or `srvctl`. Give the app one (`invoices_app`), so you can later stop or relocate that service without touching the PDB name. On a single instance, inside the PDB, as a DBA:

```sql
BEGIN
  DBMS_SERVICE.CREATE_SERVICE(service_name => 'invoices_app', network_name => 'invoices_app');
  DBMS_SERVICE.START_SERVICE('invoices_app');
END;
/

```

On RAC or with Grid Infrastructure, use `srvctl add service` instead, so the clusterware owns it. And if you have a vendor jar with a SID baked into its URL that you can't change, `USE_SID_AS_SERVICE_LISTENER=ON` exists for exactly that, with listener-wide side effects ([the trade-off is spelled out here](https://ggorantala.dev/ora-12505-listener-does-not-know-sid/?ref=ggorantala.dev)).

## SID vs service name in sixty seconds

If a teammate asked me this at the coffee machine:

- The SID names an instance. The service name names what you want to connect to. Apps connect to services.
- In JDBC, a colon before the name means SID, a slash means service. `@//host:1521/service` is the form to standardise on.
- In a multitenant database, the PDB's name is also its default service. That's why `/FREEPDB1` works and `:FREEPDB1` gets ORA-12505.
- `/FREE` connecting doesn't mean it's right. It's the root container. Check `CON_NAME`.
- The TNS alias never leaves your machine. If it can't be resolved you get ORA-12154, and no listener was involved. Unsure which of the connection errors you have? [ORA-12514 vs ORA-12541 vs ORA-12154](https://ggorantala.dev/ora-12514-vs-ora-12541-vs-ora-12154/?ref=ggorantala.dev) sorts them.

## What people search after this one

### How do I find the SID and service name of my Oracle database?

From any session, `SELECT sys_context('USERENV','INSTANCE_NAME'), sys_context('USERENV','SERVICE_NAME') FROM dual;` gives the SID and the service you came in through. On the server, `lsnrctl services` lists every registered service and its instance. For PDBs, `SELECT name, open_mode FROM v$pdbs;` shows the names whose default services you can use.

### Is the PDB name always the same as the service name?

Every PDB gets a default service with the same name, created automatically, and it's always started when the PDB is open. But a PDB can have other services too, and if `DB_DOMAIN` is set the service may carry the domain. Check `v$active_services` or `lsnrctl services` rather than assuming.

### Should I use SID or SERVICE\_NAME in tnsnames.ora?

`SERVICE_NAME`, unless you're pinned to an old tool that only knows SIDs. A `(SID=...)` entry can't reach a PDB and can't use RAC services or failover. Changing `SID=` to `SERVICE_NAME=` in `CONNECT_DATA`, with the PDB's service as the value, is usually the whole change.

### Is a TNS alias the same thing as a service name?

No. The alias is a label in your client's `tnsnames.ora` that expands to a host, port and service. They often look alike (`INVOICES` vs `invoices_app`), which is half the confusion. A wrong alias gives ORA-12154 on the client; a wrong service inside a correct alias gives ORA-12514 from the listener.