Logo F2FInterview

Oracle Database Interview Questions

Q   |   QA

If you have installed an Oracle server or an Oracle client tool on your local system, the TNS is automatically installed with a simple configuration file, tnsnames.ora, to define Oracle connect identifiers.

For example, if you have Oracle XE server installed, you will have the tnsnames.ora located at oraclexeapporacleproduct10.2.0serverNETWORKADMIN. It should contain a connect identifier called XE defined as:

XE =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)(HOST = localhost)
(PORT = 1521)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
 

DSN (Data Source Name) is an ODBC connection identifier for Windows applications. Here is how you can define a DSN on your Windows system:

► Go to Control Panel.
► Go to Administrative Tools.
► Run Data Sources (ODBC).
► Go to System DSN tab.
► Click the Add button.
► Select the "Oracle in XE" driver.
► Enter Data Source Name: f2f_DSN.
► Enter Description: f2finterview DSN Oracle Setting.
► Enter TNS Service Name: XE.
► Click the Test Connection button.
► Enter User Name: f2f.
► Enter Password: retneclgg.
► Click the OK button.

You should see a "Connection successful" as shown in the following picture:
DSN Setting for Oracle ODBC Driver 

Once you got a DSN defined in the ODBC manager that connects to an Oracle server, you can connect a normal MS Access document to the Oracle server, and link an Access table to Oracle table. The tutorial below gives you a good example:

► Start MS Access with a new database file.
► Go to File menu.
► Select Get External Data.
► Select Import.... The Import dialog box shows up.
► Select Files of type: ODBC Database(). The Select Data Source dialog box shows up.
► Click the Machine Data Source tab. You should see the DSN name "f2f_DSN" you defined earlier.
► Select "f2f_DSN".
► Enter User Name: f2f.
► Enter Password: retneclgg.

You should see the Oracle ODBC Driver Connect dialog box as shown in the picture below:
Import Oracle tables to MS Access

Click the OK button to continue. You should see a list of tables available for you to import from the Oracle server as shown in the picture below:
Importing Oracle tables via ODBC 

If you are running Windows IIS Web server and serving ASP Web pages, you can get data from Oracle servers into your ASP pages through ODBC drivers. To do this, you need to install the correct Oracle ODBC driver and define a DSN on the IIS Web server.

Then you can use ADODB objects to connect to the Oracle server over the ODBC driver in your ASP pages. The tutorial example below gives you a good example:

<%

   Set oConn = Server.CreateObject("ADODB.Connection")

   oConn.Open "DSN=f2f_DSN;UID=f2f;PWD=retneclgg"

   Set oRS = oConn.Execute("SELECT * FROM dev_faq")

   Response.write("<p>Data from Oracle server via ODBC:")

   Response.write("</pre>")

   Do While NOT oRS.EOF

      Response.Write(oRS("ID") & vbcrlf)

      oRS.MoveNext

Loop

Response.write("</pre>")

oRS.close

oConn.close

%> 

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: