Tuesday, February 21, 2017

is date function in Netezza

Check for valid date/time-stamp
There is so such built-in function , but you can user regexp to validate the value. Below the code. It will return true if it is valid time-stamp else false.

Select SQLEXT.regexp_like(current_timestamp ,'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'



CASE  WHEN  REGEXP_LIKE(COl1,'[0-9]' )  THEN  'NUMBER ONLY' ELSE COl1  END  as COl1

nz_migrate - Migrating data from one netezza box to another (or same) box


nz_migrate 

Purpose of  this command is to copy or migrate data from one one NPS server to another. It can be also used to make a copy of a database/table on the same server.


Sample Command : 
./nz_migrate -shost <source Host name>  -thost <Target Host name> -sdb  <Source Database Name> -tdb  <Target Database Name> -suser  <Source User Name> -spassword <Source Password> -tuser <Target User Name> -tpassword <Target Password>  -t <list of tables , seperated by comma. >   -cksum fast -genStats Full -threads 5  -CreateTargetTable yes -CreateTargetDatabase yes   >> /tmp/nz_migrate_0220_3.log &


If you are want to migrate all table under database (don't mention -t flag) -

./nz_migrate -shost <source Host name>  -thost <Target Host name> -sdb  <Source Database Name> -tdb  <Target Database Name> -suser  <Source User Name> -spassword <Source Password> -tuser <Target User Name> -tpassword <Target Password>    -cksum fast -genStats Full -threads 5  -CreateTargetTable yes -CreateTargetDatabase yes   >> /tmp/nz_migrate_0220_3.log &



If you are migrating data to new box, I will recommend you to run this command on new box. If you run this command on new box, it will save some memory and processing of your old box.


Note : You might get some error message saying "group/user "username" not found, "function 'COVAR_POP(FLOAT8, FLOAT8)' does not exist" , ignore it while doing the migration. These errors might not have any impact on data transfer.