I need to connect to a remote Oracle database using SQL Developer. I tried to create a new connection and I would like to know what exactly is A SID? Is it a parameter I need to check in my Oracle database?
SID (System ID) is the name of the database you are connecting to. A server can host multiple databases, so you need to specify the name.
See also: http://www.orafaq.com/wiki/ORACLE_SID
You can get it like this, once you're connected, but given the situation, that might not be very helpful. :D
select sys_context('userenv', 'instance_name') from dual
SID = Instance name as defined at instance creation on the database server.
On the database server, check the tnsnames.ora file:
SERVICE_NAME=
or
SID=
Related
I am trying to create a db link by giving this command
CREATE DATABASE LINK dblink
CONNECT TO qqitsmrep_read IDENTIFIED BY etl#t0pread
USING '(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=pldbitsr0031vm.bmwgroup.net)(PORT=1708))
(CONNECT_DATA=(SERVICE_NAME=ITSM Reporting))
)';
but not sure the service name is correct or not and also when i test the db link i get the below error
The connection looks like this
SQL Developer connection says that
Host is pldbdco0024vm.bmwgroup.net, but you used pldbitsr0031vm.bmwgroup.net
DCODB is SID, while you used Service Name which doesn't seem to be correct
Port is 1595, while you used 1708
Basically, you should check what TNSNAMES.ORA says (or ask your DBA).
Try
CREATE DATABASE LINK dblink
CONNECT TO qqitsmrep_read IDENTIFIED BY etl#t0pread
USING '(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=pldbdco0024vm.bmwgroup.net)(PORT=1595))
(CONNECT_DATA=(SID=dcodb))
)';
I'm not an Oracle guy, but I find that I need to touch on some oracle resources to respond to a new report request. I'm working at an office where the connection to an oracle server uses LDAP and I can't get to the connection info. I do have an ODBC connection on my machine, so I can get into the database through MS Access. But I'd like to be able to connect with SQL Developer so I can do more useful profiling on the tables.
Is there any way to use my ODBC connection through Access to tease out Hostname, Port, and SID/Service name so I can connect through SQL Developer?
It seems I do not have permissions to the UTL_INADDR functions.
Since you have an ODBC connection defined already, you can open the ODBC Data Source Administrator on your computer (Goto the start menu and type ODBC in to search for it).
In the ODBC Data Source Administrator select the data source for the database in question (it may be on the User, System or File DSN tab) and click the Configure button.
From the Configuration screen you will be able to see the TNS Service Name for the connection.
The TNS Service Name should be all you'll need to supply to SQL Developer when creating the connection. Aside from your account credentials of course.
You can query SID and Hostname like this:
select instance_name, host_name from v$instance;
Afaik there is no way to query the port name from the database, see also this article on Ask TOM on this subject:
You cannot get the port -- the port is not necessarily known to the
database. The listener need not be running on the same machine with
the database, a single listener might be servicing many databases. A
database may have many listeners servicing it.
Currently I am trying to understand how can two databases communicate to each other (for instance: get data from one to another).
Detailed description
I have two Oracle databases, one on Windows and latter on Oracle VirtualBox. On Windows DB I have one user (PAI) with single table called TESTME. On VirtualBox, only user (PAI_VB) was created. Now, I want to display the content of the TESTME table from SQL Developer from VB.
I have done
I want to display table TESTME using LINK statement:
CREATE DATABASE LINK LINK_TO_PAI
CONNECT TO PAI IDENTIFIED BY PAI
USING 'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=myIP)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=XE))';
Note: data from 'DESCRIPTION' section were taken from tnsname.ora file on Windows.
Having that, via following query I will manage to display table:
SELECT * FROM PAI.TESTME#LINK_TO_PAI;
Unfortunately, it does not work.
Error from console
ORA-12154: TNS:could not resolve the connect identifier specified
12154. 00000 - "TNS:could not resolve the connect identifier specified"
*Cause: A connection to a database or other service was requested using
a connect identifier, and the connect identifier specified could not
be resolved into a connect descriptor using one of the naming methods
configured. For example, if the type of connect identifier used was a
net service name then the net service name could not be found in a
naming method repository, or the repository could not be
located or reached.
*Action:
- If you are using local naming (TNSNAMES.ORA file):
- Make sure that "TNSNAMES" is listed as one of the values of the
NAMES.DIRECTORY_PATH parameter in the Oracle Net profile
Questions
Could you please propose solution to my problem (I know that in *Action section there is a hint but still I cannot solve it).
Maybe, you could introduce me another way to make communication between two databases possible.
EDIT
I managed to connect from my VB machine to one on Win10 via SQLDeveloper and SQLPlus. Unfortunately, using Oracle LINK I can not access data from database.
SOLVED !!
I managed to solve my issue. The problem laid in LINK. Since following part:
'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=myIP)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=XE))'
was inside tnsnames.ora file i should define my link as follows:
CREATE DATABASE LINK LINK_TO_PAI
CONNECT TO PAI IDENTIFIED BY PAI
USING 'xe';
After that minor change, I was able to freely us LINK in my example. Cheers :)
Here's what you need to have for a working database link:
Network connectivity between the two hosts.
Oracle Listener process running on the host you want to connect to.
Correct TNS entry while creating the link.
Correct username and password to connect to the remote database.
The TNS-12154 error you're getting means the database running on the virtual host can't get to XE's listener using the description you gave it.
Make sure you're using the correct IP address when trying to connect to your Windows host from your virtual machine.
Run tnsping from your virtual environment to see if it can get to the Windows host listener.
tnsping 'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=your_windows_host_ip_from_step_1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE))'
or just tnsping XE if you have the TNS entry stored as XE in tnsnames.ora file on your virtual machine.
See also: Oracle documentation — Testing Connections.
Once you get OK response from tnsping try connecting to XE with sqlplus (sqlplus PAI/PAI#XE) or via SQL Developer running on the virtual host. If you can connect that way your database link should also work with the same TNS entry.
This is a tricky part of oracle because there are a number of diverent ways to make a connection.
I suggest that you begin to make sure that you have a tnsnames.ora file both on windows and in your virtualbox environment. What os are you running in VirtualBox by the way?
In both tnsnames.ora files both databases should be named. Easiest to make them identical.
Then connect with sql*plus from windows to your database in VirtualBox and from VirtualBox to your database on Windows.
Just to make sure your network and tns config are OK.
If this works recreate your db-link with the servce alias from tnsnames after using. This should work.
I only have SQL Developer installed. What other programs do I need to install to create a local database. Please provide links.
SQL Developer is a client that access to a database server to extract data.
You need a database server.
If you operate with SQLDeveloper probably you like to install Oracle. There is a simplified version of Oracle that is called Oracle-XE. Search it over google and download the right version for your operating system.
Give the username and password of the user you created. You can specify localhost in Host name. If you haven't modified the port on which Oracle works then give 1521. If you haven't changed SID as well then give XE. You might be able to connect with DB.
I have installed Oracle on Ubuntu with OS user oracle. When I try to connect to Oracle when logged on as different OS user (other than oracle), I get error:
SQL> connect user1/user1#orcl
ORA-12154: TNS:could not resolve the connect identifier specified
However, if I don't mention Oracle SID then I don't get any error:
SQL> connect user1/user1
Connected to:
Oracle Database
SQL>
I have declared ORACLE_HOME and SID in the user profile. But it did not work. Can someone please help me to understand the issue.
In a sense you don't really have a problem; you can connect locally using the ORACLE_HOME and ORACLE_SID environment variables, which is fine.
When you use the connect user1/user1#orcl version, the orcl is not your SID; as explained in the documentation it is an 'Oracle Net connect identifier'.
connect_identifier
An Oracle Net connect identifier. The exact syntax depends on the
Oracle Net configuration. For more information, refer to the Oracle
Net manual or contact your DBA. SQL*Plus does not prompt for a service
name, but uses your default database if you do not include a connect
identifier.
So you are connecting over a network connection, even though its to the same host, rather than internally using IPC. You don't even need to have ORACLE_SID set when you do that, because that is used for IPC and isn't part of the network connection.
Now, the connect identifier may well actually be the same string as your SID, but it doesn't have to be. Usually when you're using a single term like orcl you're using a 'net service name' which is defined in your tnsnames.ora file. (Depending on how the naming methods are configured in your sqlnet.ora, which determines how the connect identifier is resolved; but this is still the most common configuration I think).
The Oracle Net configuration can be configured using the netca configuration assistant, as the oracle user, though you can create a private tnsnames.ora to override that.
See the Oracle Net admin guide for more about how connectivity works and is configured, and the SQL*Plus user guide for a shorter version.
In order for your user1/user1#orcl connection to work you would need a tnsnames.ora entry looking something like:
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL=tcp)(HOST=my_host)(PORT=1521))
(CONNECT_DATA = (SERVICE_NAME = orcl)))
... where my_host is the DNS name or IP address of your Oracle server, and 1521 is the port the listener is configured to run on. (The listener has to be running for you to be able to connect this way, too). The SERVICE_NAME is not necessarily the same as your SID either, but depends on the database configuration; the lsnrctl status command will show what service names are available.
The ORA-12154 error is telling you that you either don't have a tnsnames.ora file at all, or that it doesn't contain an entry for the alias orcl.
As #a_horse_with_no_name points out, there are other forms of connect identifier, and you don't necessarily need a tnsnames.ora file for a network connection; the options are explained here. I've just focused on the one you were trying to use. You don't necessarily need to use any of them though since you are able to connect locally.