SQL Column Heading

Hi,
I am selecting few columns from a table using select query in UNIX shell script ans sending the results as E-mail. But the column headings are not displayed fully. Instead it displays only a part of the heading. Please help as how to display it fully.

Thanks in advance for your help.

Which database client?
Can we see the shell script?
How are you sending the mail?
Is there a column format specifier in place?

Actually no need for that info, I see the problem now, you accidentally left out a semi-colon on line 42...

1 Like

Actually i use select query in shell script and mailx command to send email. o/p which i get display as below,

STORE DI ITE ITEM CTRL CTRL_DT                                                  
----- -- --- ---- ---- ---------                                                
01743             1234 19-MAY-15  

But i ant this to display column name as STORE_NUM DIVISION. . Similarly other columns are not displayed fully.

What sql command, and any other commands, are you using?

There are lots of database systems out there and even more database clients to query them. The language to query relational databases is standardised but the commands to instruct the database client how to format the results is not.
So without at least the information what database client you use we are left to guess which could fit you.
For mysql the pager command can be used to format the output, but the example you give does not look like unmodified output from this client.
Oracles sqlplus provides the column command. If this is the client you use you can follow this link to the documentation.
I never worked with db2 or other database products on unix, so can't say how they handle this issue.

i use sqlplus,

${ORACLE_HOME}/bin/sqlplus -s ${DB_LOGIN}/${DB_PASSWD} <<EOF
SET FEEDBACK OFF
SET HEADING ON
spool /tmp/file1.TMP
SELECT column1,column2,column3 FROM table1;
quit

o/p of this doesn't shows the column headings fully. Even tried COLUMN column1 HEADING COLUMN1.. But no hope

Give a format specifier that is wide enough to display the heading. Something like:

column STORE_NUM heading 'STORE_NUM DIVISION' format a18

Edit: I just saw you posted this in the wrong section - better post in "Shell Scripting" next time.

1 Like
Moderator comments were removed during original forum migration.