Distribution keys
Each table in an IBM® Netezza® database has only one distribution key. The key can consist of one to four columns of the table.
Important: You cannot update the columns that you select
as distribution keys.
You can use the following Netezza SQL
command syntax to create tables and specify distribution keys:
- To create an explicit distribution key, the Netezza SQL
syntax is:
CREATE TABLE <tablename> [ ( <column> [, … ] ) ] DISTRIBUTE ON [HASH] ( <column> [ ,… ] ) ;
The phrase DISTRIBUTE ON specifies the distribution key, the word HASH is optional.
- To create a table without specifying a distribution key, the Netezza SQL
syntax is:
CREATE TABLE <tablename> (col1 int, col2 int, col3 int);
The Netezza system selects a distribution key. There is no way to guarantee what that key is and it can vary depending on the Netezza software release.
- To create a random distribution, the Netezza SQL
syntax is:
CREATE TABLE <tablename> [ ( <column> [, … ] ) ]DISTRIBUTE ON RANDOM;
You can also use the NzAdmin tool to create tables and specify the distribution key. For more information about the CREATE TABLE command, see the IBM Netezza Database User’s Guide.