2013-03-27 5 views
9

sto usando qui sotto comando in ambiente Unix per la connessione al database Oracle:Connect to Oracle DB utilizzando sqlplus

sqlplus test/[email protected]'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname.com)(PORT=1521)))(CONNECT_DATA=(SID=mysid))' 

Ma io sono sempre sotto l'errore:

Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus statements. 

Usage 1: sqlplus -H | -V 

    -H    Displays the SQL*Plus version and the 
        usage help. 
    -V    Displays the SQL*Plus version. 

Usage 2: sqlplus [ [<option>] [{logon | /nolog}] [<start>] ] 

    <option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S] 

Please help me dove sono io fare errori nell'usare il comando.

+1

Le parentesi sono equilibrate? –

+0

Sì, questo è il problema, ho perso 1 parentesi di chiusura nel comando. Grazie mille David. – Chaitanya

+1

Se il client è configurato per consentire EZCONNECT per la risoluzione dei nomi Oracle, è possibile utilizzare sqlplus test/[email protected]: 1521/mysid invece - molto più semplice IMHO. –

risposta

0

se si desidera connettersi con il database Oracle

  1. Aprire SQL prompt dei
  2. connettersi con sysdba per XE- conn/come sysdba per IE - conn sys as sysdba
  3. quindi avviare il database se da sotto comando avvio;

una volta avviato indica che ora è possibile accedere al database di Oracle. se vuoi connettere un altro utente puoi scrivere conn username/password ad es. conn scott/tiger; sarà mostrata collegato ........

+0

Si prega di non includere collegamenti a siti Web non collegati nelle risposte - sembra spam. –

9

provare questo: sqlplus USER/[email protected]//hostname:1521/SID

+0

Per la porta, dovresti controllare 'oracle \ product \ 11.2.0 \ dbhome_1 \ NETWORK \ ADMIN \ tnsnames.ora', a volte è 1522 se hai già installato un altro Oracle. – coanor

+0

Ho 1526 su delle basi, e sì, può essere diverso. Piuttosto ovvio per me. – Alexander

1

modo Easy (utilizzando XE):

1). Configurare il tnsnames.ora

XE = 
    (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = HOST.DOMAIN.COM)(PORT = 1521)) 
    (CONNECT_DATA = 
     (SERVER = DEDICATED) 
     (SERVICE_NAME = XE) 
    ) 
) 

è possibile sostituire HOST.DOMAIN.COM con l'indirizzo IP, la porta TCP di default è 1521 (ckeck) e cercare quel nome di questa configurazione è XE

2) . Utilizzando la vostra applicazione di nome sqlplus:

sqlplus [email protected] 

sistema dovrebbe essere sostituito con un utente autorizzato, e mettere la vostra password quando pronta appaiono

3).Vedere al firewall per qualsiasi possibilità di alcune porte TCP bloccate e risolvere il problema se appare

0
tnsping xe --if you have installed express edition 
tnsping orcl --or if you have installed enterprise or standard edition then try to run 
--if you get a response with your description then you will write the below command 
sqlplus --this will prompt for user 
hr --user that you have created or use system 
password --inputted at the time of user creation for hr, or put the password given at the time of setup for system user 
hope this will connect if db run at your localhost. 
--if db host in a remote host then you must use tns name for our example orcl or xe 
try this to connect remote 
hr/[email protected] or hr/[email protected] --based on what edition you have installed 
0

Come David Aldridge ha spiegato, i tuoi parentesi dovrebbero iniziare subito dopo il comando sqlplus, quindi dovrebbe essere:

sqlplus 'test/[email protected](DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname.com)(PORT=1521)))(CONNECT_DATA=(SID=mysid))'

0

sarebbe qualcosa di simile

sqlplus -s /nolog <<-! 
connect ${ORACLE_UID}/${ORACLE_PWD}@${ORACLE_DB}; 
whenever sqlerror exit sql.sqlcode; 
set pagesize 0; 
set linesize 150; 
spool <query_output.dat> APPEND 
@$<input_query.dat> 
spool off; 
exit; 
! 

qui

0.123.
ORACLE_UID=<user name> 
ORACLE_PWD=<password> 
ORACLE_DB=//<host>:<port>/<DB name> 
0

Diversi modi per collegare Oracle Database da utente Unix sono:

[[email protected] ~]$ sqlplus scott/tiger 

[[email protected] ~]$ sqlplus scott/[email protected] 

[[email protected] ~]$ sqlplus scott/[email protected]:1521/orcl 

[[email protected] ~]$ sqlplus scott/[email protected]//192.168.244.128:1521/orcl 

[[email protected] ~]$ sqlplus "scott/[email protected](DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ole1)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))" 

Si prega di consultare la spiegazione al link: https://stackoverflow.com/a/45064809/6332029

Grazie!