Skip to main content

Netezza Interview Questions and Answers

Question and Answer What the utilities available in nz/bin? Driver: libnzodbc.so , Utilities  : nzconvert, nzds, nzevent, nzhw, nzload, nzodbcsql, nzpassword, nzreclaim, nzrev, nzsession, nzsql, nzstate, nzstats, nzsystem Where is the Configuration file available? Config file odbc.ini is available in nz/lib and it contains the Database Source properties and Connection parameters. What is NZSQL utility? This utility can be run from any machine on which it is installed i.e. it does not have be from netezza box itself. This utility can be used to run any sql statement like select or insert statement on the netezza database. In the below usage you see data extracted from the table into a output file and in the second mzsql command the data is also gzipped. nzsql -host <netezz_db_servername> -d <database> -u <username> -pw <password> -c -c "select * from tablename" -o /root/home/outputfilename.txt; What is NZLOAD utility? This utility can be us

Srquences in Netezza

A sequence is a named object in a database or schema that supports the get next value method. By using sequences, you can generate unique numbers that can be used as surrogate key values for primary key values, where the identification of rows within a table would involve a large, compound primary key, or for other purposes.
A sequence value is an integer that you can use wherever you would use numeric values. IBM® Netezza® supports user sequences for the four integer types: byteint, smallint, integer, and bigint.
You create a sequence with an initial value, an increment, a minimum, and a maximum value. You also specify whether the sequence cycles, which determines whether the sequence starts over when the endpoint is reached.

Create a sequence

Use the CREATE SEQUENCE statement to create a sequence, which is an object from which users can generate unique numbers.
To create a sequence, use the CREATE SEQUENCE statement and specify the options in any order.
CREATE SEQUENCE <sequence name> [as <data type> <options>]
Where the options are the following:
START WITH <start value>
INCREMENT BY <increment>
no minvalue | minvalue <minimum value>
no maxvalue | maxvalue <maximum value>
cycle | no cycle
The options have the following parameters:
  • The default minvalue is no minvalue, which is defined to be 1.
  • The default maxvalue is no maxvalue and is the largest value by data type that the sequence can hold.
  • The default start value is the minvalue for an increasing sequence, and the maxvalue for a decreasing sequence. The startvalue must be within the range of the minvalue and maxvalue.
  • The default increment is 1.
  • By default, sequences do not cycle.
When a user generates a sequence number, the system increments the sequence independently of the transaction committing or rolling back. Therefore, a rollback does not return the value to the sequence object. If two users concurrently increment the same sequence, the sequence numbers each user acquires might have gaps because the sequence numbers are being generated by the other user.
Sequences also can have gaps because the IBM® Netezza® caches sequence values on the host and SPUs for efficient operation.

Alter a sequence

You can alter a user sequence by resetting any sequence option, including the name and owner of the sequence. To change the starting value, use the RESTART WITH option.
To alter a sequence, use the ALTER SEQUENCE statement and specify the options in any order.
ALTER SEQUENCE <sequence name> <options>

Where the options are the following:
OWNER to <new owner>
RENAME TO <new sequence name>
RESTART WITH <start value>
INCREMENT BY <increment>
no minvalue | minvalue <minimum value>
no maxvalue | maxvalue <maximum value>
cycle | no cycle

Drop a sequence

Although you can drop a sequence, remember that system locking occurs if you attempt to drop a sequence that is in use by a running query. In addition, if the sequence is referenced by other metadata, subsequent use of that metadata results in an error, for example if the sequence is referenced in a view definition.
To drop a sequence, use the DROP SEQUENCE statement and specify the sequence name.
DROP SEQUENCE <sequence name>


Comments

Popular posts from this blog

Creating Netezza User Defined Functions in C++

STEPS TO CREATE NETEZZA UDF For creating UDF in netezza we should have knowledge of C++ programming. The post explains how to create netezza UDF which finds greater value out of two values passed. STEP 1 : Write C++ code for the function. The code refers the the below header files. #include "udxinc.h" #include "udxhelpers.h"   And namespace list is mentioned below using namespace nz :: udx :: dthelpers; using namespace nz :: udx; The sample code for the greater of two numbers is mentioned below. #include "udxinc.h" #include "udxhelpers.h" #include <ctype.h> using namespace nz::udx; class greaterOfTwo : public Udf {   public :     static Udf* instantiate();     virtual ReturnValue evaluate()     {       int64 first = int64Arg(0);       int64 second = int64Arg(1);       int64 returnValue = 0;       if (first > second) returnValue = first; else returnValue = second;       NZ_UDX_RETURN_INT64(returnValue);     } }; Udf*

Netezza Interview Questions and Answers

Question and Answer What the utilities available in nz/bin? Driver: libnzodbc.so , Utilities  : nzconvert, nzds, nzevent, nzhw, nzload, nzodbcsql, nzpassword, nzreclaim, nzrev, nzsession, nzsql, nzstate, nzstats, nzsystem Where is the Configuration file available? Config file odbc.ini is available in nz/lib and it contains the Database Source properties and Connection parameters. What is NZSQL utility? This utility can be run from any machine on which it is installed i.e. it does not have be from netezza box itself. This utility can be used to run any sql statement like select or insert statement on the netezza database. In the below usage you see data extracted from the table into a output file and in the second mzsql command the data is also gzipped. nzsql -host <netezz_db_servername> -d <database> -u <username> -pw <password> -c -c "select * from tablename" -o /root/home/outputfilename.txt; What is NZLOAD utility? This utility can be us