vineri, 20 noiembrie 2015

Kill all the blocking sessions (Real Application Cluster)

Give it a run as sysdba, from any instance:
begin
for obj in (
        SELECT s.inst_id,
               s.sid,
               s.serial#,
               p.spid,
               s.username,
               s.program
               FROM   gv$session s JOIN gv$process p 

                      ON p.addr = s.paddr 
                      AND p.inst_id = s.inst_id
               WHERE   blocking_session is not null 

                       and s.type != 'USER')
    loop
    execute immediate 'alter system kill session '''||obj.sid||','||obj.serial#||',@'||obj.inst_id||''''||' ';
end loop;
end;
/

luni, 16 noiembrie 2015

Grant select on all tables of a schema to another user

Just replace the "user1" and "user2" names. User2 is the grantee and user1 the owner.

BEGIN
FOR c IN (SELECT owner, table_name FROM all_tables WHERE owner='user1') LOOP
      EXECUTE IMMEDIATE 'grant select on '||c.owner||'.'||c.table_name||' to user2';
   END LOOP;
END;


and for all privileges: 

BEGIN
FOR c IN (SELECT owner, table_name FROM all_tables WHERE owner='user1') LOOP
      EXECUTE IMMEDIATE 'grant all privileges on '||c.owner||'.'||c.table_name||' to user2';
   END LOOP;
END;

vineri, 13 noiembrie 2015

ORA-31202: DBMS_LDAP: LDAP client/server error: Sizelimit exceeded

The problem is a parameter of the LDAP Server: MaxPageSize.

On the server:

c:\>ntdsutil.exe
ntdsutil: Ldap policies
ldap policy: connections
server connections: Connect to server ServerName
Binding to ServerName ...
Connected to ServerName using credentials of locally logged on user
server connections: q
ldap policy: Show Values
Policy                          Current(New)

MaxPoolThreads              8
MaxDatagramRecv             1024
MaxReceiveBuffer            10485760
InitRecvTimeout             120
MaxConnections              5000
MaxConnIdleTime             900
MaxActiveQueries            20
MaxPageSize                 1000
MaxQueryDuration            120
MaxTempTableSize            10000
MaxResultSetSize            262144
MaxNotificationPerConn      5
ldap policy: set MaxPageSize to 100000
ldap policy: Commit Changes
ldap policy: Show Values

Policy                          Current(New)

MaxPoolThreads              8
MaxDatagramRecv             1024
MaxReceiveBuffer            10485760
InitRecvTimeout             120
MaxConnections              5000
MaxConnIdleTime             900
MaxActiveQueries            20
MaxPageSize                 100000
MaxQueryDuration            120
MaxTempTableSize            10000
MaxResultSetSize            262144
MaxNotificationPerConn      5

ldap policy: q
ntdsutil: q
Disconnecting from ServerName