Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-12-02 · container image gvenzl/oracle-free:23-slim
ORA-12154 is the classic "TNS:could not resolve the connect identifier specified" error. In Oracle 26ai the text changed to "Cannot connect to database. Cannot find alias ... in ...", and the alias and file name are masked with *********.
This page covers database links: the USING alias does not exist on the database server, or it was written with a domain suffix (.WORLD) the server does not use. Creating the link succeeds; the error only appears the first time you query through it. We reproduced it on Oracle 26ai Free.
01DB link created with a tnsnames alias that does not exist on the server
CREATE DATABASE LINK erp_link ... USING 'ERPDB' returned no error. The first SELECT ... FROM user_tables@erp_link failed with ORA-12154, because the alias is looked up only when the link connects.
Setup
GRANT CREATE DATABASE LINK TO lab_a, lab_b;Grant succeeded.CREATE DATABASE LINK erp_link CONNECT TO lab_b IDENTIFIED BY lab USING 'ERPDB';Database link created.SELECT COUNT(*) FROM user_tables@erp_link;SELECT COUNT(*) FROM user_tables@erp_link
*
ERROR at line 1:
ORA-12154: Cannot connect to database. Cannot find alias ********* in *********.
Help: https://docs.oracle.com/error-help/db/ora-12154/COLUMN db_link FORMAT a20
COLUMN username FORMAT a10
COLUMN host FORMAT a20
SELECT db_link, username, host FROM user_db_links;DB_LINK USERNAME HOST
-------------------- ---------- --------------------
ERP_LINK LAB_B ERPDB
1 row selected.user_db_links shows the link's HOST is ERPDB, an alias, not a host:port/service string.
DROP DATABASE LINK erp_link;
CREATE DATABASE LINK erp_link CONNECT TO lab_b IDENTIFIED BY lab USING 'localhost:1521/FREEPDB1';Database link dropped.
Database link created.We dropped the link and recreated it with an EZConnect string, USING 'localhost:1521/FREEPDB1'. The same query then returned a row.
SELECT COUNT(*) FROM user_tables@erp_link; COUNT(*)
----------
0
1 row selected.02Alias written with a domain suffix (.WORLD) that the server does not use
The link was created with USING 'FREEPDB1.WORLD', the full name you often see in a client's tnsnames.ora. Creating it worked, but the first query through pdb_link failed with ORA-12154. On this server the alias is FREEPDB1 without a domain, so FREEPDB1.WORLD was not found.
Setup
GRANT CREATE DATABASE LINK TO lab_a, lab_b;Grant succeeded.CREATE DATABASE LINK pdb_link CONNECT TO lab_b IDENTIFIED BY lab USING 'FREEPDB1.WORLD';Database link created.SELECT COUNT(*) FROM user_tables@pdb_link;SELECT COUNT(*) FROM user_tables@pdb_link
*
ERROR at line 1:
ORA-12154: Cannot connect to database. Cannot find alias ********* in *********.
Help: https://docs.oracle.com/error-help/db/ora-12154/COLUMN db_link FORMAT a20
COLUMN host FORMAT a20
SELECT db_link, host FROM user_db_links;DB_LINK HOST
-------------------- --------------------
PDB_LINK FREEPDB1.WORLD
1 row selected.user_db_links shows HOST = FREEPDB1.WORLD: the alias carries a .WORLD suffix.
DROP DATABASE LINK pdb_link;
CREATE DATABASE LINK pdb_link CONNECT TO lab_b IDENTIFIED BY lab USING 'FREEPDB1';Database link dropped.
Database link created.We recreated the link with USING 'FREEPDB1' (no domain). The same query then returned a row.
SELECT COUNT(*) FROM user_tables@pdb_link; COUNT(*)
----------
0
1 row selected.FAQ
Why does ORA-12154 now say "Cannot find alias *********"?
That is the 26ai wording of ORA-12154. In our run, the alias and the file name were both shown as *********, so check the link's HOST in user_db_links to see which alias was used.
The DB link was created without error. Why ORA-12154 later?
CREATE DATABASE LINK does not connect. The USING alias was resolved only on the first query through the link, and that is where ORA-12154 appeared.
Can I create a DB link without editing tnsnames.ora?
Yes. We used an EZConnect string host:port/service_name in USING ('localhost:1521/FREEPDB1'), and the link worked with no tnsnames entry.
The alias works from my PC. Why ORA-12154 through the DB link?
A DB link resolves the alias on the database server, not on your PC. In our run, FREEPDB1.WORLD failed on the server while FREEPDB1 worked, so use the name the server knows or an EZConnect string.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0