Category Archives: Oracle

How to Configure the ODBC on Oracle XE Client

Even Oracle veterans may encounter some challenges when it comes to setting an odbc  using the Oracle XE Client.    As every DBA will tell you, you will need to configure the tnsnames.ora  (using  net configuration Assistant or by going  to oracle home\network\admin and edit it manually). After that, theTNS Service name in the ODBC will be populated with the entries from the tnsnames.ora file. You will only be required to choose the appropriate entry and you should be good to go.
This was the case in all the latest Oracle releases However If you will download the Oracle XE client you will quickly discover  that there is no tnsnames.ora under the Oracle client XE directory structure. In addition, the network\admin directory is not there as well.
Oracle documentation explains (In their usual user friendly way) how to connect to the Data Base using a connection string (username/password@[//]host[:port][/service_name] where service name is usually XE and port is 1521) but it is not that obvious how to configure the odbc to use this.
The solution is simple enough (once you find it). All that needs to be done is to type  the connection string  on the ODBC’s “ TNS Service Name” field.  Just add the line 127.0.0.1/XE (no need to use the drop down) and test the connection.
If the Data Base is on a different machine, you can replace 127.0.0.1 with the address of the remote server.

Installing Oracle on a machine with DHCP

During Oracle installation on a windows machine that is configured to use DHCP in order to obtain its IP address, the Following message will probably be displayed:

Checking Network Configuration requirements …
Check complete. The overall result of this check is: Failed <<<<
Problem: The install has detected that the primary IP address of the system is DHCP-assigned.
Recommendation: Oracle supports installations on systems with DHCP-assigned IP addresses; However, before you can do this, you must configure the Microsoft LoopBack Adapter to be the primary network adapter on the system.  See the Installation Guide for more details on installing the software on systems configured with DHCP.

As the error message say, this due to the fact that you are trying to install Oracle on a machine that is using DHCP to obtain its IP address. You can still install oracle on a machine without a constant IP address. All you need to do is configure the LoopBack adapter:

Install the Loopback adapter
1)     Go to the control panel and choose add hardware
2)    The Add Hardware wizard will be displayed, click Next
3)    Choose “Yes, I have already connected the hardware” and click Next
4)    An hardware list will be displayed. Navigate to the bottom of the list and choose “Add new hardware       device”
5)    Choose Install the hardware that I manually select from a list (Advance)”
6)    Choose “Network adapter”
7)    Choose “Microsoft” on the left side of the window and “Microsoft Loopback Adapter” on the right             window”
8)    Click Next and verify that Microsoft Loopback Adapter is about to install and click next again and       finish.

Configure the loop back adapter
1)    Go to control panel – network connections, you will see a new network connection.
2)    Choose “local area connection 2” (the name may vary but basically it is the one we just added) and       click properties.
3)    Click on tcp/ip and then properties.
4)    Enter an IP address and a subnet mask (you can use 1.1.1.2 and subnet 255.255.255.0)

Go to network connection and click on Advanced settings under the Advanced menu and verify that the loopback adapter is in the first one. (Update: it look like this step is optional because it seems to work in most cases anyway)

Now you can continue your oracle installation.

ORA-01758 when trying to alter table

If you are trying to add a new Not NULL columns to a table and you get the following error:

ORA-01758: table must be empty to add mandatory (NOT NULL) column

Since the values in the new column are null (after all, you just added the column) the new constraint can not be satisfied.

There are several option to overcome ORA-01758:

1) provide a default value for the column.

ALTER TABLE table-name ADD column-name VARCHAR2(15) DEFAULT ‘X’ NOT NULL

If you don’t want the default value you can remove it after the column will be populated with the new data.

2) Add the column without the NOT NULL constraint,

ALTER TABLE table-name ADD (column-name VARCHAR2(15));

— add the data

UPDATE table-name set column-name=’x’;

— apply the NOT NULL  constraint.

ALTER TABLE table-name MODIFY (column-name NOT NULL)

3) Empty the table, apply the NOT NULL and add the data back to the table

How to move tablespace to a new location

1)    Take the tablespace offline
ALTER TABLESPACE tablespace-name OFFLINE;
2)    Use the OS to Move the tablespace to the new location
3)    Run the following command:
ALTER TABLESPACE tablespace-name RENAME DATAFILE ‘OS path to old tablespace\tablespace-datafile- name.dbf’ TO ‘OS path to new location\tablespace-datafile-name.dbf’;
4)    Take the tablespace back online
ALTER TABLESPACE tablespace-name ONLINE;
If the following error is displayed
ORA-01113: file n needs media recovery
ORA-01110: data file n: ‘new location file name’

Issue the the following command:
recover datafile ‘new location file name ‘;
and take the tablespace back online
ALTER TABLESPACE tablespace-name ONLINE;

Oracle enterprise manager is not accepting host logon credentials

When trying to perform backup and other operations using the Oracle enterprise manager, The Oracle Enterprise manager asks you for the host credentials (operating system login). You may get the following error even if you are sure that you provided the correct credentials:

Validation Error
Examine and correct the following errors, then retry the operation:
ERROR: Wrong password for user

To solve this, you need to give the user you are trying to connect with the privilege, “Logon as batch job”.
on windows, go to
Administrative Tools –>
Local Security Policy –>
Security Settings  –>
Local Policies –>
User Rights Assignments –>
Double click “Log on as batch job” and add the user.