Friday, October 24, 2014

what the ways to generate DDL of various objects in NPS?


 nz_get_view_definition
Usage:    nz_get_view_definition  <database>  <view>

Purpose:  Display the definition (the SQL) that the view will execute.
nz_ddl*                              
nz_ddl_aggregate*           
nz_ddl_comment*            
nz_ddl_database* 
nz_ddl_diff* 
nz_ddl_ext_table* 
nz_ddl_function*  
nz_ddl_grant_group* 
nz_ddl_grant_user*
nz_ddl_group*  
nz_ddl_history_config*
nz_ddl_library* 
nz_ddl_mview* 
nz_ddl_object*  
nz_ddl_owner*
nz_ddl_procedure*
nz_ddl_security*  



how to check the creator of the user in Netezza?

Usage:    nz_get_user_owner  <user>

Purpose:  List the owner (creator of) the specified user.

Inputs:   The user name is required.

Outputs:  The owner of the user is returned

[nz@nps bin]$ nz_get_user_owner bala
ADMIN

how to check the table fragmentation details of tables on Netezza Database?

 nz_frag -h

Usage:    nz_frag <database> <table/mview>

Purpose:  Dump out extent/page allocations in order to visualize table fragmentation.

          Storage is allocated an extent at a time (3MB).  Within the extent, it is
          then filled up with records a page at a time (128KB).  The pages are filled
          front-to-back.  Once all of the available space in the extent is used up, a
          new extent is allocated.

          Usually, all of the 24 pages within an extent are in-use.  But there are
          exceptions.

          o  The very last extent for a table (on any given dataslice) will probably
             only be partially filled.  So any remaining pages will be unused (empty).
             Unused pages are not scanned.

          o  If you have done a "GROOM TABLE <tablename> PAGES ALL;" then any pages
             that contain 100% deleted/groomable rows will be marked as being empty.
             They will no longer be used/scanned, though they still exist within the
             extent.  If all 24 pages in the extent are empty, the extent will be
             removed from the table and added back to the global storage pool.

          o  Clustered Base Tables (those created with an ORANIZE ON clause) may only
             partially fill any given cluster/extent.

Inputs:   The database and table/mview names are required.

          -dsid <nn>    By default, data slice 1 (the 1st amongst all data slices)
                        will be reported upon.  You can choose to look at the
                        information for a different data slice if you wish.

                        Storage allocation/usage is specific to each dataslice.
                        Rather than showing all info for all dataslices (which
                        could be voluminous), this script will concentrate on
                        just one dataslice, which should provide a good
                        representative sample.

                        However, if you want to see ALL information for ALL
                        dataslices ALL at once, then specify:  -dsid all

Outputs:  A dump of the extent+page storage information for this table/mview (for
          a single dataslice).

          The "Extent ID" that is displayed is the system assigned extent number.
          The values for contiguous extents will vary by 32.

          The "#" column is a simple, one-up number ... to make things easier to
          read.

          The "gap" column is used to indicate whether the extents are contiguous
          on disk.  If the extents are contiguous (if the gap is 0) then a blank
          will be displayed.  Otherwise, this number will represent the number of
          other extents (not belonging to this table) between this extent and the
          prior extent.

          "Used/Unused Pages  (./0)" is used to represent which of the 24 pages
          within each extent are (or are not) in use.  A "." indicates the page
          is in use.  A "0" indicates the page is not being used.

          Example follows:

     $ nz_frag SYSTEM TEST_TABLE

        Database: SYSTEM
     Object Name: TEST_TABLE
     Object Type: TABLE
     Object ID  : 10578974
      Data Slice: 1

      Extent ID | DataSlice | #  | gap | Used/Unused Pages  (./0)
     -----------+-----------+----+-----+--------------------------
       38886368 |         1 |  1 |     | 0.......................
       38886432 |         1 |  2 | 1   | .0......................
       38886560 |         1 |  3 | 3   | ..0.....................

how to find objects owned by specific owners in Netezza database?

Find objects that are owned by users -- other than the 'admin' user
nz_find_object_owners  [user]

how to search object in Netezza box?

we have to use nz_find_object to find object in NPS and it  will check the object in all DB's on NPS server.



nz_find_object table1

  The Object Name Is   | It Is Of Type | Its 'objid' Is | In The Database
-----------------------+---------------+----------------+-----------------
 table1 | TABLE         |       11711150 | DB_name_
 table1 | TABLE         |       10057249 | DB_name__FEB14
 table1 | TABLE         |       11487344 | DB_name__SEP16

How to generate DDL for user in Netezza?

nz_ddl_user <USER_NAME>

\echo
\echo *****  Creating user:  "<USER_NAME>"
CREATE USER <USER_NAME> WITH PASSWORD 'password' ;

\echo
\echo *****  Updating password for user:  "<USER_NAME>"
UPDATE _t_user_options SET passwd = '$1$/+CQzTNi+1I9$QqgdELb4KLkNiFqr8cN4Jg==' WHERE usename = ^<USER_NAME>^;
UPDATE _t_user         SET passwd = '$1$/+CQzTNi+1I9$QqgdELb4KLkNiFqr8cN4Jg==' WHERE usename = ^<USER_NAME>^;

it will set the password as 'password'

how to add a user user to power group in Netezza box?

 Adding users to ACCESS groups

ALTER GROUP POWER_USER ADD USER <username>

How to check how many objects details in Netezza database?

use nz_stats will tell you the details about various versions of tables and object count.

nz_stats

Host Name                     nsdwt03
Model Number                  IBM PureData System for Analytics N1001-005
Software Revision             7.0.2.P8
Today's Date                  2014-10-24
Uptime (In Days)              384.82
Instance                      69
#'s Of Objects
     Databases                10
     Tables                   7,801
     External Tables          251
     Row Secure Tables        0
     Views                    203
     Materialized Views       0
     Sequences                0
     Synonyms                 5
     Users                    72
     Groups                   11
     Aggregates               0
     Functions                26
     Procedures               3,763
     Libraries                0
# Of Versioned Tables         58
     Total # Of Versions      120
Table Size (MB)
     Minimum                  0
     Average                  1,920
     Maximum                  687,092
     Total                    14,985,326
MView Size (MB)
     Minimum                  0
     Average                  0
     Maximum                  0
     Total                    0
Tables Per Database
     Minimum                  6
     Average                  774
     Maximum                  1,898
MViews Per Database
     Minimum                  0
     Average                  0
     Maximum                  0
MViews Per Table (Max)        0
Columns Per Table
     Minimum                  1
     Average                  14
     Maximum                  265
Columns Per MView
     Minimum                  0
     Average                  0
     Maximum                  0
Table Row Size (Bytes)
     Minimum                  28
     Average                  825
     Maximum                  52,064
MView Row Size (Bytes)
     Minimum                  0
     Average                  0
     Maximum                  0
Column Types (for TABLEs)
     BYTEINT                  1,057
     SMALLINT                 2,621
     INTEGER                  21,324
     BIGINT                   1,154
     NUMERIC                  25,577
     FLOAT                    0
     DOUBLE                   1,083
     CHAR                     1,191
     VARCHAR                  44,552
     NCHAR                    0
     NVARCHAR                 44
     DATE                     5,161
     TIME                     74
     TIMESTAMP                5,083
     TIMETZ                   0
     INTERVAL                 5
     BOOLEAN                  2
     ST_GEOMETRY              0
     VARBINARY                0
Column Types (for MVIEWs)
     BYTEINT                  0
     SMALLINT                 0
     INTEGER                  0
     BIGINT                   0
     NUMERIC                  0
     FLOAT                    0
     DOUBLE                   0
     CHAR                     0
     VARCHAR                  0
     NCHAR                    0
     NVARCHAR                 0
     DATE                     0
     TIME                     0
     TIMESTAMP                0
     TIMETZ                   0
     INTERVAL                 0
     BOOLEAN                  0
     ST_GEOMETRY              0
     VARBINARY                0
Column Types (for VIEWs)

How to check total and used space on Netezza applicance

you may use the below query to find the NPS DS used and free space details.

nz_storage_stats

nz@Netezza1 bin]$ nz_storage_stats

# Of DataSlices               92
Extents Per Dataslice         121,515
Storage Per DataSlice  (GB)   356.000
Storage Used           (GB)
     Minimum                  128.259
     Average                  136.918
     Maximum                  150.911
Storage Used            (%)
     Minimum                  36.028
     Average                  38.460
     Maximum                  42.391
Total Storage
     Available         (TB)   31.984
     Used              (TB)   12.301
     Used               (%)   38.460
     Remaining         (TB)   19.683
     Remaining          (%)   61.540

Tuesday, October 14, 2014

voting disk and OCR IN RAC

OCR: It created at the time of Grid Installation. It’s store information to manage Oracle cluster-ware and it’s component such as RAC database, listener, VIP,Scan IP & Services.
Minimum 1 and maximum 5 copy of OCR is possible.
Voting Disk: It manage information about node membership. Each voting disk must be accessible by all nodes in the cluster.If any node is not passing heat-beat across other note or voting disk, then that node will be evicted by Voting disk.
Minimum 1 and maximum 15 copy of voting disk is possible.
New Facts:
  • We can store OCR And Voting disk on ASM or certified cluster file system.
  • We can dynamically add or replace voting disk & OCR.
  • Backup of Voting disk using “dd” command not supported.
  • Voting disk and OCR can be keep in same disk-group or different disk-group
  • Voting disk and OCR automatic backup kept together in a single file.
  • Automatic backup of Voting disk and OCR happen after every four hours, end of the day, end of the week
  • You must have root or sudo privilege account to manage it.
To find current location of Voting disk:
-bash-3.2$ crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   9095dc8a0e4d4f40bfd3a8b6ed02d7c1 (/dev/dbq_rawvote) [OCRVD]
Located 1 voting disk(s).

to check OCR

bash-3.2$ ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       3308
         Available space (kbytes) :     258812
         ID                       :  376930295
         Device/File Name         :     +OCRVD
                                    Device/File integrity check succeeded

                                    Device/File not configured

                                    Device/File not configured

                                    Device/File not configured

                                    Device/File not configured

         Cluster registry integrity check succeeded

         Logical corruption check bypassed due to non-privileged user

to check local OLR

ddcfusdbq01 /grid/app/11.2.0/grid/bin #./ocrcheck -local
Status of Oracle Local Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2704
         Available space (kbytes) :     259416
         ID                       :  367014315
         Device/File Name         : /grid/app/11.2.0/grid/cdata/ddcfusdbq01.olr
                                    Device/File integrity check succeeded

         Local registry integrity check succeeded

         Logical corruption check succeeded