IBM Support

Displaying non-ASCII characters with Netezza SQL

Question & Answer


Question

How to load and store non-ASCII characters in a NPS table?

Answer

Here is an example that explains process of load and store non-ASCII characters in a NPS table.

Steps are as follows:

1) Let's creating a table using with following schema. Remember to use NVARCHAR data type for store non ASCII characters. The 'ADGROUP' and 'KEYWORD' are two columns used here for store non ASCII characters. You cannot use CHAR or VARCHAR to store non ASCII characters. The CHAR and VARCHAR take 1 byte of space and most of the special character or non ASCII characters require either 2, 3 or 4 bytes.

    CREATE TABLE INTCHAR_TEST
    (
    CURRENCY      CHARACTER VARYING(10),
    PROFILE_ID    NUMERIC(10,0),
    PROFILE_NAME  CHARACTER VARYING(50),
    CAMPAIGN_NAME CHARACTER VARYING(50),
    CHANNEL       CHARACTER VARYING(25),
    ADGROUP       NVARCHAR(100),
    KEYWORD       NVARCHAR(100),
    MATCH_TYPE    CHARACTER VARYING(25),
    STATUS        CHARACTER VARYING(25),
    LAND_URL      CHARACTER VARYING(500),
    QUALITY_SCORE NUMERIC(38,10),
    DEVICE        CHARACTER VARYING(25),
    KEYWORD_ID_IN_KENSHOO NUMERIC(10,0),
    DATE          CHARACTER VARYING(200),
    IMPRESSIONS   NUMERIC(10,3),
    CLICKS        NUMERIC(10,3),
    CONVERSIONS   NUMERIC(10,3),
    COST          NUMERIC(38,18),
    AVG_POS       NUMERIC(38,18),
    REV           NUMERIC(38,18)
    )
    DISTRIBUTE ON RANDOM;

2) Use the following command to load data from a file. (loading data from TEST.CSV file):
    cat test.csv | nzload -host NZ35011-H1 -u admin -pw xyz -db sanjitc -t
    INTCHAR_TEST -delim 44 -encoding internal -skiprows 1 -nullValue ''
    -ctrlChars -quotedValue NO -fillRecord -maxErrors 1 -outputdir
    /export/home/nz/sanjitc/

3) To display the non ASCII character while querying the table:
      - Keep thing simple, use all default setting in Netezza
      - If you are using Putty, by default Putty uses Latin1. Please check your putty terminal setting in Window -> Translation. It most probably set to Latin1.
      Change that to UTF8

[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"IBM Netezza Analytics","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"Standard","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
17 October 2019

UID

swg21960825