Thursday, March 14, 2013

Make sure you are connected to the correct Oracle database with SqlPlus

Using Oracle11g, you may find yourself in a situation where you are sure that you created a user, but when you try to connect you receive an ORA-01017: invalid username/password; logon denied.

Sometimes this is due to a log string like this:

sqlplus SYS as SYSDBA/pass@db

which seems valid. It prompts you for a password and then proceeds as normal. However, this syntax is not valid. Instead of warning you, it will connect to the default database! Any user you then create will not be in the right database. The correct syntax is:


sqlplus SYS@db/pass as SYSDBA


or like this without a password:

sqlplus SYS@db as SYSDBA


Check what you are connected to:

select name from v$database;

Monday, March 11, 2013

Oracle11g drop ACL

If you have an already existing ACL, you will get errors like this:

ERROR at line 1:
ORA-31003: Parent /sys/acls/ already contains child entry resolve.xml
ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 226
ORA-06512: at line 1

To drop the previous ACL, use  DROP_ACL command:
BEGIN
   DBMS_NETWORK_ACL_ADMIN.DROP_ACL(
      acl => 'resolve.xml');
END;

ORA-44416 Unresolved Principal

Having an issue creating an ACL (Access Control List) in Oracle 11g database.
 BEGIN  
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (  
   acl => 'resolve.xml',  
   description => 'Access Control',  
   principal => 'usera',  
   is_grant => TRUE,  
   privilege => 'connect');  
 END;  

I was receiving errors like this:

ERROR at line 1:
ORA-44416: Invalid ACL: Unresolved principal 'usera'
ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 226
ORA-06512: at line 2

The solution is as simple as having the principal in uppercase!

   principal => 'USERA',