Search code examples
messagevertica

How to suppress the output message in vertica


I am running a series of SQL statement in vertica which is saved in abc.sql file and transferring the output to a text file.

I wanted to suppress the warning message and stop it from going to text file

abc.sql 

UPDATE  public.aks SET name='Akshay';

SELECT 2;

SELECT 3;

SELECT 4;

output.txt

OUTPUT
100
(1 row)
?column?
2
(1 row)
?column?
3
(1 row)
?column?
4
(1 row)

Solution

  • You need to switch output on and off within the script.

    Preparing the table:

    CREATE TABLE public.aks AS
    WITH 
    -- need a series of integers ..
    i AS (
      SELECT MICROSECOND(ts) AS i , 'slartibartfast' AS name FROM (
        SELECT TIMESTAMPADD(microsecond,  1,'2000-01-01'::TIMESTAMP) AS tm UNION ALL
        SELECT TIMESTAMPADD(microsecond,100,'2000-01-01'::TIMESTAMP) AS tm
      )x
      TIMESERIES ts AS '1 microsecond' OVER(ORDER BY tm)
    )
    SELECT * FROM i;
    

    Once that is done - the script looks like this:

    -- send all output to nirvana
    \o /dev/null
    UPDATE  public.aks SET name='Akshay';
    -- send output back to screen
    \o
    SELECT 2;
    SELECT 3;
    SELECT 4;
    

    And the output:

    2
    3
    4
    

    Is this what you're looking for?