问题
I have just installed Oracle - DevSuitehome2, Oracle Database 10g Express Edition and Oracle Developer Suit - DevSuiteHome2. I am new to this Oracle forms, Oracle Reports, etc. During installation, it asked for the password. I entered it. It was written that use your password in SYS and SYSTEM Database accounts. After installation was completed I started SQL *Plus. I entered SYSTEM as username and my password.
ERROR:
ORA-12154 :TNS:could not resolve the connect identifier specified
I also tried SYS as my username but still same error. I opened cmd and typed:
C:\>sqlplus /nolog
SQL> conn / as sysdba
connected.
SQL> desc dba_users
NAME NULL? TYPE
------ ------ --------
USERNAME VARCHAR2(30)
USERID NUMBER
PASSWORD VARCHAR2(30)
.
.
SQL>select username,password from user_dba;
USERNAME PASSWORD
----------- -------------
SYS XXXXXXXXXX
SYSTEM XXXXXXXXXX
SCOTT XXXXXXXXXX
HR XXXXXXXXXX
.
.
All passwords were written in complex form so to simplify it I thought to change any one of the password. So, I wrote :
SQL> alter user HR identified by password;
user altered.
Then I tried to use these while opening SQL *Plus. It did not work. I don't know what's the host string now. Can I get the complete information about users, passwords and host string ? I tried to search for tnsnames.ora file too but could not find out. All files, folders are all mess.
回答1:
Usernames and passwords:
SELECT USERNAME, PASSWORD
FROM DBA_USERS;
Passwords are always encrypted so you will not get much out of it
host name:
SELECT sys_context('USERENV', 'HOST') FROM DUAL;
sys_context works great for many, many things:
http://psoug.org/reference/sys_context.html
If you have access to the command line you can use listener status to get some more information.
LSNRCTL> STATUS
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=net)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.0.0 -
Beta
Start Date 15-JAN-2008 12:02:00
Uptime 0 days 0 hr. 5 min. 29 sec
Trace Level support
Security OFF
SNMP OFF
Listener Parameter File /oracle/network/admin/listener.ora
Listener Log File /oracle/network/log/listener.log
Listener Trace File /oracle/network/trace/listener.trc
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=net)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=sales-server)(PORT=2484)))
Services Summary...
Service "sales1.us.example.com" has 1 instance(s).
Instance "sales", status READY, has 1 handler(s) for this service...
Service "sales2.us.example.com" has 1 instance(s).
Instance "sales", status READY, has 2 handler(s) for this service...
The command completed successfully
Source: http://docs.oracle.com/cd/E11882_01/network.112/e10835/lsnrctl.htm#CIHGHCGJ (Oracle Database Net Services Reference)
来源:https://stackoverflow.com/questions/17170125/how-to-find-host-string