Reputation: 11
I need to create a single dynamic select query for different tables in Netezza.
I get the list of columns for any table by using following query:
select * from _V_SYS_COLUMNS where TABLE_NAME='Table Name'
But I need to append all the values of Column ‘Column_Name’ separated by comma and store it into a variable:
var= col1,col2,....
And then I will pass this ‘var’ in select query to run it for different tables.
Note: I cannot use Select * because all the columns are not required.
Upvotes: 1
Views: 863
Reputation: 291
$ COLUMNS=`nzsql -A -t -c "select column_name from _v_sys_columns where table_name = 'NZ_CHECK_DISK_SCAN_SPEEDS';" -R "," | sed -e "s/,$//"`
$ echo "$COLUMNS"
THE_DATASLICE,THE_EXTENT,THE_PAGE,THE_ROW,FILLER1,FILLER2
Upvotes: 0