Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to specify column header titles in a SQL CREATE TABLE statement?

Re: How to specify column header titles in a SQL CREATE TABLE statement?

From: Rhino <rhino1_at_NOSPAM.sympatico.ca>
Date: Tue, 12 Oct 2004 16:31:41 -0400
Message-ID: <saXad.27521$3C6.991758@news20.bellglobal.com>

"Thomas Jerkins" <tomjerk_at_hotmail.com> wrote in message news:ckhavu$ihj$01$1_at_news.t-online.com...
> When I write a create table SQL statement I want to add some information
about the column heading of each column.
> How does the exact syntax for the create table look like (which includes
this column data look)?
>
> How do I add later column headings ?
>

I am assuming that you are using the phrase 'column heading' to mean the title that appears above a column when you run an SQL Select from the DB2 command line or in the DB2 Command Center. For example, given:

select lastname, salary
from employee
where empno in ('000010', '000020');

results in:

LASTNAME SALARY
------------ ---------
HAAS 52750.00
THOMPSON 41250.00 I assume that your question refers to 'LASTNAME' and 'SALARY' in this result and that you want to control what these headings are. If that's NOT what you mean by 'column headings', please clarify.

It is possible that SQLServer, Oracle and DB2 handle these column headings the same way as a result of complying with the same standards. Then again, they may not not; I am only answering with respect to DB2.

The Create Table statement does not have any effect on the column heading that appears when you query the table. To control the column heading, you use an 'as' expression within the Select statement. For example:

select lastname as Employee_Last_Name, salary as Employee_Pay from employee
where empno in ('000010', '000020');

results in:

EMPLOYEE_LAST_NAME EMPLOYEE_PAY

---------------------------    ------------------
HAAS                                52750.00
THOMPSON                        41250.00

If you want embedded blanks within the column heading, you need to embed the column heading within quotes. For example:

select lastname as "Employee Last Name", salary as "Employee Pay" from employee
where empno in ('000010', '000020');

results in

EMPLOYEE LAST NAME EMPLOYEE PAY

--------------------------    -----------------
HAAS                            52750.00
THOMPSON                    41250.00

[Please note that I "took some liberties" with the result sets shown in these examples due to the proportional fonts used in my newsreader. In the real world:

- the lastname values will be left-justified under the LASTNAME heading
- the salary values will be right-justified under the SALARY heading.
- the headings will always be uppercase if the query is executed in the DB2
command line but will match the case of the query if the query is executed in the Command Center]

Rhino Received on Tue Oct 12 2004 - 15:31:41 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US