How do you add header row into a file created through Teradata Aster act?

1.5k Views Asked by At

I've used the syntax below to export a table from Teradata Aster into a csv file:

\o file_name.csv
COPY table_name TO STDOUT WITH DELIMITER ',';
\o
\install file_name.csv

This code creates a csv with data exported from the Aster table. But, it does not contain the header row. The data is large enough that an export through Teradata Studio Express is not viable. Currently, my solution is to manually insert the header in a text editor post COPY. I'm wondering if there is a way to do this in act?

1

There are 1 best solutions below

0
On

When you first log into ACT, you will find a welcome screen:

Welcome to act 06.00.00.02, the Aster nCluster Terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with act commands
       \g or terminate with semicolon to execute query
       \q to quit

You can use the \h COPY to look up the documentation for you COPY function. Like so:

Command:     COPY
Description: copy data between a file and a table
Syntax:
COPY tablename [ ( column [, ...] ) ]
    FROM STDIN
    [ [ WITH ]
          [ DELIMITER [ AS ] 'delimiter' ]
          [ NULL [ AS ] 'null string' ]
          [ CSV [ QUOTE [ AS ] 'quote' ]
                [ ESCAPE [ AS ] 'escape' ] ] ]
    [ LOG ERRORS
      [ [ INTO errortablename ] [ WITH LABEL [ AS ] 'label' ] | NOWHERE ]
      [ ERRORLIMIT [ AS ] limit ]
    ]

COPY tablename [ ( column [, ...] ) ]
    TO STDOUT
    [ [ WITH ]
          [ DELIMITER [ AS ] 'delimiter' ]
          [ NULL [ AS ] 'null string' ]
          [ CSV [ QUOTE [ AS ] 'quote' ]
                [ ESCAPE [ AS ] 'escape' ] ] ]

Here there are no options to copy with headers. So I think you might have to add the headers back after you've copied.