Reputation: 157
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.
Upvotes: 0
Views: 1963
Reputation: 11
you can sqlplus usr1/usr1@testdb when you create connect string. It means that you need to entry in tnsnames.ora file
Upvotes: 0
Reputation: 191275
The error is because you don't seem to have an entry for testdb
in your tnsnames.ora
file. You could add one, manually or with the configuration tools netca
etc); or you could bypass that with the 'easy connect' syntax:
sqlplus username/password@//hostname:port/service_name
If this is on your local machine, the default port and the service name matches the SID, that could be simolified a bit to:
sqlplus usr1/usr1@//localhost/testdb
You can verify the service name in v$parameters
, or with lsnrctl services
.
You can read more about connections and naming methods.
If your are connecting to a database on the same machine as the client, and you are using the same ORACLE_HOME
, you don't need to use TNS/SQL*Net at all. With ORACLE_SID
set to the right value, just doing this will connect locally:
sqlplus usr1/usr1
Upvotes: 0