Wednesday, March 28, 2018

All about Netezza database renaming & changing owner

Here is the step by step for Netezza DB renaming & changing ownership.


SYSTEM.ADMIN(ADMIN)=> select DATABASE,OWNER,CREATEDATE from _v_database where DATABASE='NZ_PRD1_NEW';
   DATABASE   | OWNER |     CREATEDATE
--------------+-------+---------------------
 NZ_PRD1_NEW | ADMIN | 2018-03-21 18:47:00
(1 row)

SYSTEM.ADMIN(ADMIN)=> alter database NZ_PRD1_NEW rename to NZ_PRD1_NEW1;
ALTER DATABASE


SYSTEM.ADMIN(ADMIN)=> select DATABASE,OWNER,CREATEDATE from _v_database where DATABASE='NZ_PRD1_NEW1';
   DATABASE    | OWNER |     CREATEDATE
---------------+-------+---------------------
 NZ_PRD1_NEW1 | ADMIN | 2018-03-21 18:47:00
(1 row)


SYSTEM.ADMIN(ADMIN)=> alter database NZ_PRD1_NEW1  owner to admin;
ALTER DATABASE

SYSTEM.ADMIN(ADMIN)=> select DATABASE,OWNER,CREATEDATE from _v_database where DATABASE='NZ_PRD1_NEW1';
   DATABASE    |  OWNER  |     CREATEDATE
---------------+---------+---------------------
 NZ_PRD1_NEW1 | ADMIN | 2018-03-21 18:47:00
(1 row)

SYSTEM.ADMIN(ADMIN)=> drop database NZ_PRD1_NEW1;
DROP DATABASE
SYSTEM.ADMIN(ADMIN)=> select DATABASE,OWNER,CREATEDATE from _v_database where DATABASE='NZ_PRD1_NEW1';
 DATABASE | OWNER | CREATEDATE
----------+-------+------------

(0 rows)

Friday, March 16, 2018

Netezza error when trying to change DB name


ISSUE:
when I tried to change the Netezza DB name,it throws the below error and did not allow to rename.

SYSTEM(ADMIN)=> alter database NZDB1 rename to NZDB1_old;
ERROR:  ALTER DATABASE: database "NZDB1" is being accessed by other users
SYSTEM(ADMIN)=> \q
nz@NZ_server_name:/export/home/nz> nzsession

ID    Type     User      Start Time              PID   Database State  Priority Name Client IP      Client PID Command
----- -------- --------- ----------------------- ----- -------- ------ ------------- -------------- ---------- ------------------------
62849 sql-odbc NZUSER 02-Mar-18, 03:45:18 EST 14040 NZDB1 idle   normal        10.128.211.171       7716 SHOW ENABLE_ROW_SECURITY
92451 sql      ADMIN     15-Mar-18, 16:01:35 EDT  6134 SYSTEM   active normal             127.0.0.1       6133 SELECT session_id, clien


Solution:
checked the session associated with DB  and cleared it and rename the DB ,it went fine.

nz@NZ_server_name:/export/home/nz> nzsession abort -id 62849 -force
nz@NZ_server_name:/export/home/nz> nzsession

ID    Type User  Start Time              PID   Database State  Priority Name Client IP Client PID Command
----- ---- ----- ----------------------- ----- -------- ------ ------------- --------- ---------- ------------------------
92454 sql  ADMIN 15-Mar-18, 16:02:36 EDT 10149 SYSTEM   active normal        127.0.0.1      10148 SELECT session_id, clien

nz@NZ_server_name:/export/home/nz> nzsql
Welcome to nzsql, the IBM Netezza SQL interactive terminal.

Type:  \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

SYSTEM(ADMIN)=> alter database NZDB1 rename to NZDB1_old;
ALTER DATABASE
SYSTEM(ADMIN)=>  alter database NZDB1_NEW rename to NZDB1;
ALTER DATABASE
SYSTEM(ADMIN)=> \l
           List of databases
           DATABASE           |  OWNER
------------------------------+---------
 NZDB1                        | ADMIN
 NZDB1_OLD                    | ADMIN

Thursday, March 15, 2018

oracle database error during DB startup


Issue:
I have faced some issue  & DB did not open when I restart the database using Pfile  and got the below error.

SQL> startup pfile='initORA1.ora' mount;
ORACLE instance started.

Total System Global Area 2.5655E+10 bytes
Fixed Size                  2258352 bytes
Variable Size            2617248336 bytes
Database Buffers         2.3018E+10 bytes
Redo Buffers               16904192 bytes
ORA-00201: control file version 11.2.0.4.0 incompatible with ORACLE version
11.1.0.0.0
ORA-00202: control file: '/appdb1/oradata/oradb1.redoctrl01/control01.ctl'

Cause:
looks like the compatible  parameter value different in P & SP file

Solution:
corrected the Pfile according to SP file compatible value  and restarted the database and it opened without any issues.

oracle database memory upgrade error

when I tried to increase the sga_max_size and sga_target and got  the below error.


ISSUE:

alter system set SGA_MAX_SIZE=12288M scope=spfile;

 alter system set SGA_TARGET=12G scope=spfile;


SQL> startup pfile='initOra1.ora' mount;
ORA-00844: Parameter not taking MEMORY_TARGET into account
ORA-00851: SGA_MAX_SIZE 12884901888 cannot be set to more than MEMORY_TARGET 9663676416.
ORA-01078: failure in processing system parameters

Cause:
when I checked the parameter file and it contains AMM parameter enabled.

Solution:
remove  or comment the memory_target from the parameter file and startup with pfile  with sga_max_size & sga_target.

Tuesday, March 13, 2018

How to find locks on Netezza database?

Here is the step by step to find  the blocking or locking session in Netezza database
Please get the SQL statement  that's running on the server and get the table that you have issue and check locking session with the  DB  name and table name

nz_show_locks  NZ_DB1 table_name1



 Database: NZ_DB1

   Object: table_name1

 ObjectId: 13231729

Timestamp: 2018-03-01 17:12:49



=======================================================================================================



The following session(s) are HOLD'ing a lock on the object



 Requested | Granted @ | Wait Time | SESSIONID | PROCESSID | USERNAME  |    LOCKMODE     |           Current SQL Command

-----------+-----------+-----------+-----------+-----------+-----------+-----------------+------------------------------------------

 15:21:05  | 15:21:05  | 00:00:00  |    448002 |     14511 | user1 | AccessShareLock | SELECT count(a11.CHC_ID),a11.day_id, DEC

 16:01:12  | 16:01:12  | 00:00:00  |    448260 |      3201 | user1 | AccessShareLock | SELECT count(a11.CHC_ID),a11.day_id, DEC

 16:11:40  | 16:11:40  | 00:00:00  |    448329 |      1450 | user1 | AccessShareLock | SELECT count(a11.CHC_ID),a11.day_id, DEC

 16:51:37  | 16:51:37  | 00:00:00  |    448632 |     20697 | USR2  | AccessShareLock | SELECT MAX (a13.MONTH_DESC) MONTH_AT_DIS

(4 rows)



=======================================================================================================



The following sessions are WAIT'ing to access the object



 Requested | Granted @ | Wait Time | SESSIONID | PROCESSID |  USERNAME  |      LOCKMODE       |           Current SQL Command

-----------+-----------+-----------+-----------+-----------+------------+---------------------+------------------------------------------

 16:54:35  |           | 00:18:15  |    448653 |     30742 | USER4     | AccessExclusiveLock | ALTER TABLE NZ_DB1.NZUSER.TABLE_NAME

 16:55:27  |           | 00:17:23  |    448679 |      2638 |   USR5    | AccessShareLock     | SELECT To_Date (a.WFINDATE_DAY_ID, 'yyyy

 16:56:55  |           | 00:15:55  |    448680 |      4580 | USER3     | AccessShareLock     | select a13.MONTH_ID MONTH_ID1, max(a13.m

 16:57:48  |           | 00:15:02  |    448623 |     18626 | USER3     | AccessShareLock     | CREATE TEMP TABLE T6GXA4WPZMD003 as sele

 16:58:53  |           | 00:13:57  |    448624 |     18625 | USER3     | AccessShareLock     | CREATE TEMP TABLE TJCDUKW1BMD004 as sele

(5 rows)



=======================================================================================================

Monday, March 12, 2018

How to take backup of users  only in Netezza database?

Please use the below command to take user only backup.it will create a folder .
/SYSTEM/20180312164028/1/USERS/md


/nz/kit/bin/nzbackup -users -dir /export/home/nz/ > user_backup.log


Backup of global objects completed successfully.

Wednesday, February 14, 2018

How to check the user last login detail on the netezza database?

Here is the script to check the user last login detail.

connect to history DB and execute this query.

select username, max(time) from "$v_hist_log_events" where op_type ='session create' group by username order by 1;  

Thursday, February 1, 2018

oracle database manual upgrade failed with below error




Issue:
oracle database manual upgrade failed with below error 

when I tried to upgrade oracle database to 11.2.0.4  had issues during the upgrade.

catupgrade ran almost  70% and come out from the SQL prompt and trowed the below error.



catupgrad failed with below error.


RROR at line 1:
ORA-04063: package body "SYS.DBMS_STATS_INTERNAL" has errors
ORA-06508: PL/SQL: could not find program unit being called:
"SYS.DBMS_STATS_INTERNAL"
ORA-06512: at "SYS.DBMS_STATS", line 385
ORA-06512: at line 2



Solution:

when I check with oracle and they suggested us to validate these packages and re-run the catupgrade again.



drop table sys.WRI$_OPTSTAT_SYNOPSIS$;

create table wri$_optstat_synopsis$
( bo# number not null,
group# number not null,
intcol# number not null,
hashvalue number not null
) partition by range(bo#)
subpartition by hash(group#)
subpartitions 32
(
partition p0 values less than (0)
)
tablespace sysaux
pctfree 1
enable row movement;
descr sys.WRI$_OPTSTAT_SYNOPSIS$

--- check if the desc command shows:
Name Null? Type
----------------------------------------- -------- ----------------------------
BO# NOT NULL NUMBER
GROUP# NOT NULL NUMBER
INTCOL# NOT NULL NUMBER
HASHVALUE NOT NULL NUMBER

catalog
catproc
@?/rdbms/admin/prvtstas.plb
@?/rdbms/admin/prvtstat.plb

Can we add space to table space when we the oracle DB in upgrade mode?

Can we add space to table space when we the oracle DB in upgrade mode?

I came to the situation where I need to add some space to during the oracle database upgrade .
checked with oracle and we can add the space during the DB upgrade with just altering the data-file size.But oracle recommended to resize the data-file instead of adding new data file.



Tuesday, January 16, 2018

database error after upgrading oracle database to 11.2.0.4

Issue:
Recently I had upgraded the oracle database from 11.1.0.7 to 11.2.0.4 and upgrade  went fine and one of the application job failed with below error.

ORA-29532: Java call terminated by uncaught Java exception: java.security.AccessControlException: the Permission (java.lang.RuntimePermission accessClassInPackage.sun.misc) has not been granted to O1MGR. The PL/SQL to grant this is dbms_java.grant_permission( 'O1MGR', 'SYS:java.lang.RuntimePermission', 'accessClassInPackage.sun.misc', '' )

Root cause:

This is the bug on the 11204 .

solution:
Changes in the 11.2.0.4 DB required additional grants be enabled for the GLOGOWNER user.

1. Log into the Database as SYSDBA
2. Run the following:
begin
 dbms_java.grant_permission('GLOGOWNER'
  , 'SYS:java.lang.RuntimePermission'
  ,'accessClassInPackage.sun.misc', '' ) ;
end;
/

Refer DOC:(Doc ID 1945137.1)