Reputation: 39
How to suppress column heading and end from Select statement in Netezza?
Select Column_type from _v_sys_columns where table_name = 'EMP';
Output:
Coulms ------- EMP_NM EMP_SAL row count(2)
I want to suppress Column name (Columns ------
) and row count(2)
.
I appreciate your help.
Upvotes: 2
Views: 1218
Reputation: 9
nzsql -h ${host_name} -u ${user} -db ${dbname} -pw ${password} -A -t -c "
select table_name, type_name from _V_SYS_COLUMNS where TABLE_NAME like 'EMP%';"
it will trim the headers and align the output
Upvotes: 0
Reputation: 3887
The method for accomplishing this depends on the interface/application you are using. It's not clear from the sample output you give which you are using, but I'll venture a guess that you are using the nzsql CLI. For it, you can toggle the output of column headers (along with the trailing row count) using the \t directive.
TESTDB.ADMIN(ADMIN)=> select table_name, type_name from _V_SYS_COLUMNS where TABLE_NAME like 'EMP%';
TABLE_NAME | TYPE_NAME
------------+-----------------------
EMPLOYEES | BIGINT
EMPLOYEES | BIGINT
EMPLOYEES | CHARACTER VARYING(50)
EMPLOYEES | NUMERIC(20,2)
EMP_NM | BIGINT
EMP_SAL | BIGINT
(6 rows)
TESTDB.ADMIN(ADMIN)=> \t
Showing only tuples.
TESTDB.ADMIN(ADMIN)=> select table_name, type_name from _V_SYS_COLUMNS where TABLE_NAME like 'EMP%';
EMPLOYEES | BIGINT
EMPLOYEES | BIGINT
EMPLOYEES | CHARACTER VARYING(50)
EMPLOYEES | NUMERIC(20,2)
EMP_NM | BIGINT
EMP_SAL | BIGINT
Alternatively, you can invoke nzsql with the "-t" option for the same effect.
Upvotes: 2
Reputation: 77876
You can't just omit the header's (Not just by using NETEZZA
as far I know). You will have to use some OS command to strip the extra lines. Like, if you are currently running NZSQL
in LINUX
then probably you can use tail
and head
command to get the desired output
nzodbcsql -h <hostname> -d <db name> -u <userid> -pw <password> -q "Select Column_type from _v_sys_columns where table_name = 'EMP'"| tail -3 | head -2
Upvotes: 0