This is the continue topic with this topic:
Oracle 10g: Error when creating database manually by scripts
Basically, I had created an Oracle database named "testdb" using only batch scripts and SQL scripts.
After successfully creating a database using script, I create a script to create user for client connect to the database.
CreateUser.bat
sqlplus sys/test as sysdba @D:\Script\CreateUser.sql
CreateUser.sql
shutdown immediate;
startup;
CREATE USER usr1 IDENTIFIED BY usr1
DEFAULT TABLESPACE users
QUOTA UNLIMITED ON users;
GRANT CREATE SESSION, GRANT ANY privilege TO usr1;
exit;
Everything run ok, with no error.
Then I try to test by connecting to SQLPlus on cmd:
sqlplus usr1/usr1@testdb
This retrun the error:
ORA-12154: TNS:could not resolve the connect identifier specified
I wonder what I did wrong.
The same happen for the database I created via DBCA.
testdb
an alias in yourtnsnames.ora
? The error suggests it is not. You can put it there manually or use the net manager tool. But if the database is local, and you haveORACLE_HOME
andORACLE_SID
set properly already, why aren't you just connecting locally now? Why go through TNS at all? It isn't anything to do with the user, anyway, the error is complaining about the connect identifier, which is thetestdb
part. – Alex Poolesqlplus usr1/usr1
. The@testdb
attempts to use an alias defined intnsnames.ora
to access the database over SQl*Net. You don't need to do that if you're connecting from the same machine the database is on. – Alex PooleORACLE_SID
setting. There are ways to change your SQL*Plus prompt to show you the database name which can be a useful visual clue. But back to your question... you should read up on naming methods. With 'easy connect' you can dosqlplus usr1/usr1@//hostname:port/testdb1
, wherehostname
eitherlocalhost
or the servers real name depending on how things are configured, 1521 is the default listener port, andtestdb1
is the service name. Dolsnrctl status
to verify what those should be. – Alex Poole