Tuesday, October 14, 2014

steps to create db link from oracle to MSSQL using gateway server

1.CREATE PUBLIC DATABASE LINK "DB_link_name"
   CONNECT TO "PTC_SSRSRMS" IDENTIFIED BY VALUES '06D0D'
   USING 'DB__name'

2.tnsnames.ora on oracle server oracledb_servername

DB__name=
  (DESCRIPTION=
    (ADDRESS= (PROTOCOL=TCP) (PORT=1621) (HOST=gateway_servername))
    (CONNECT_DATA= (SID=DB__name)) (HS=OK))


3.update on C:\Oracle\11g\dg4msql
initDB__name.ora

# This is a customized agent init file that contains the HS parameters
# that are needed for the Database Gateway for Microsoft SQL Server

#
# HS init parameters
#
HS_FDS_CONNECT_INFO=sqlserver name//sql db name
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER

4.listener.ora
SID_DESC =
      (SID_NAME = DB__name)
      (ORACLE_HOME = c:\oracle\11g)
      (PROGRAM = dg4msql)
    )

5.tnsnames.ora
DB__name.WORLD =
  (DESCRIPTION=
    (ADDRESS= (PROTOCOL=TCP) (PORT=1621) (HOST=gateway_servername))
    (CONNECT_DATA= (SID=DB__name)) (HS=OK))

restore Netezza table alone when you have table level backup

lease follow the below syntax to restore the table when you take the backup using nz_backup for single table.


[nz@SERVER_NAME ~]$ nz_restore -format binary -dir /netback/backup/test/Netezza/NZ81331-H1/TEST/whdev/ -db TARGTE_DB_NAME-t ADMINISTRATOR_140923_152501



nz_restore of database TARGTE_DB_NAMEstarted on 2014-02-28 14:22:18



                         NZ_HOST:

                         NZ_USER: ADMIN

                     NZ_DATABASE: DB_NAME1

                Backup Directory: /netback/backup/test/Netezza/NZ81331-H1/TEST/whdev/

                   Backup Format: binary

                   Custom Script:

                    # Of Threads: 1

                Using stableTXid: 0

       The lastTXid assigned was: 0

                      Debug Mode: Disabled



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



Info:  table 1 of 1                                               ADMINISTRATOR_140923_152501

Info:  restore process started                                    2014-02-28 14:22:19

Info:  # of bytes to be read                                      1,650,875

Info:  reloading data              ( thread 1 of 1 )

Info:  data flowing ...

Info:  reload finished             ( thread 1 of 1 )   seconds    1

Info:  reload results              ( thread 1 of 1 )              INSERT 0 57840

Info:  data flow finished

Info:  restore process ended                                      2014-02-28 14:22:20

Info:  rate     (restore file size / # of seconds elapsed)        1,650,875

Info:  # of records reloaded                                      57,840

Info:  # of seconds elapsed                                       1



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



nz_restore of database TARGTE_DB_NAMEfinished on 2014-02-28 14:22:20



     Total # of tables processed: 1

     Total # of records reloaded: 57,840

     Total # of seconds elapsed : 1



     TOTAL restore file size    : 1,650,875

     rate  (bytes per second)   : 1,650,875

steps to do table level backup in netezza

Please find the steps and syntax to use backup the single table

[nz@SERVER_NAME DB_NAME]$ nz_backup -db DB_NAME -t ADMINISTRATOR_140923_152501 -dir /netback/backup/test/Netezza/NZ81331-H1/TEST/DB_NAME -format binary



nz_backup of database DB_NAME started on 2014-02-28 14:09:47



                         NZ_HOST:

                         NZ_USER: ADMIN

                     NZ_DATABASE: DB_NAME

                Backup Directory: /netback/backup/test/Netezza/NZ81331-H1/TEST/DB_NAME

                   Backup Format: binary

                   Custom Script:

                    # Of Threads: 1

                  Using lastTXid: 3327032

        The stableTXid value was: 3327031

                      Debug Mode: Disabled



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



Info:  table 1 of 1                                               ADMINISTRATOR_140923_152501

Info:  backup  process started                                    2014-02-28 14:09:51

Info:  estimated # of records                                     57,840

Info:  unloading data              ( thread 1 of 1 )

Info:  data flowing ...

Info:  unload finished             ( thread 1 of 1 )   seconds    0

Info:  unload results              ( thread 1 of 1 )              INSERT 0 57840

Info:  data flow finished

Info:  backup  process ended                                      2014-02-28 14:09:51

Info:  source table size                                          6,029,312

Info:  backup file size                                           1,650,875

Info:  rate     (backup file size / # of seconds elapsed)         1,650,875

Info:  ratio    (source table size / backup file size)            3.65

Info:  # of records unloaded                                      57,840

Info:  # of seconds elapsed                                       0



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



nz_backup of database DB_NAME finished on 2014-02-28 14:09:51



     Total # of tables processed: 1

     Total # of records unloaded: 57,840

     Total # of seconds elapsed : 0



     TOTAL source table size    : 6,029,312

     TOTAL backup file size     : 1,650,875

     rate  (bytes per second)   : 1,650,875

     ratio (source / backup)    : 3.65



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



[nz@SERVER_NAME DB_NAME]$ ls -ltr

total 1620

-rw-r--r-- 1 nz nz 1650875 Feb 28 14:09 ADMINISTRATOR_140923_152501.1

steps by steps table refresh between Netezza server

pre -request
target tables should have same strcuture as source tables structure.

then issue the below command to migrate the tables.

nz_migrate -shost SRCHOST_NAME -thost TRGETHOST_NAME -format binary -sdb SRCDB_NAME -tdb TRGET_NAME -suser admin -t FT_INSTOCK -threads 4 -cksum Yes -genStats Express -TruncateTargetTable Yes

script to table level restore in Netezza database?

pre -request
1.drop the tables in target
or truncate the table
2.check the table structure as like source
3.restore the database

nzrestore -db NETEZZA_CUSTOMER_SERVICE -sourcedb ABC -connector /nz/backup/STRUCT/whdev/Netezza/NZ81331-H1/ABC/20130506082020/ -dir /nz/backup/STRUCT/whdev/Netezza/NZ81331-H1/ABC/20130506082020/1/SCHEMA/md  -tables table_cust -u admin

query to check db access for each user in NPS?

select username from _v_usergroups;

scrip to restore Netezza database to another database

pre -request.

we have to drop the target database before restore ,NPS restore process automatically will create new database.once the restore is completed we will rename the database

nzrestore -db test1 -u admin -dir /netback/backup/test/ -backupset 20130605233051

script to rename Netezza database?

alter database rename <dbname> to < new name>

How to stop/start the netezza Database?

we have to issue the below command using nz user

nzstop/nzstart

How to take the DDl of database ,table of Netezza DB?

nz_ddl_database <dbname>
nz_ddl_table <dbname> <table_name>