I want to create a shell script which runs a Netezza SQL and create lookup file dbnames.lkp in a unix directory
lookup file name : dbnames.lkp
Could someone help me with nzsql command. I know just to connect to Netezza server using nzsql command and then run the queries. But my requirement is that the shell script should run connect and write the result of SQL query to a lookup file
nzsql -u $user -pw $password -d $db -host $hostname
You can query Netezza System view _v_database
to fetch all databases in the connected server, provided the user should have access.
You can create a shell script with below command and this will take care of it.
user=<user_name>
password=<password>
query="select database from _v_database;"
file=dbnames.lkp
dbname=<dbname_to_connect>
hostname=<server>
nzsql -u $user -pw $password -d $dbname -host $hostname -o $file -A -t -c "$query"
-c : will run only a single query and exit nzsql.
You can get more information from below link: