473,785 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 ?

Tom

Jul 19 '05 #1
4 21350

"Thomas Jerkins" <to*****@hotmai l.com> wrote in message
news:ck******** *****@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_N ame, salary as Employee_Pay
from employee
where empno in ('000010', '000020');

results in:

EMPLOYEE_LAST_N AME 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
Jul 19 '05 #2
Rhino wrote:
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]


Headings specified in the "as" clause will be used EXACTLY AS RECEIVED
by the DB2 command processor. If you are getting folding to upper case
then you are most likely not correctly specifying the column headings.

Under RHEL3, UDB 8.1 FP7:

db2 "select lastname as ""Lastname" " from employee where lastname like 'L%'"

LASTNAME
---------------
LUCCHESSI
LUTZ
LEE

appears correct and returns the data but does not have the correct
column heading! The operating system command line processor gets this
long before DB2 does and alters it.

db2 "select lastname as \"Lastname\" from employee where lastname like 'L%'"

Lastname
---------------
LUCCHESSI
LUTZ
LEE

yields exactly the results that are expected.
Phil Sherman

Jul 19 '05 #3

"Philip Sherman" <ps******@ameri tech.net> wrote in message
news:Tk******** *********@newss vr31.news.prodi gy.com...
Rhino wrote:
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]
Headings specified in the "as" clause will be used EXACTLY AS RECEIVED
by the DB2 command processor. If you are getting folding to upper case
then you are most likely not correctly specifying the column headings.

Under RHEL3, UDB 8.1 FP7:

db2 "select lastname as ""Lastname" " from employee where lastname like

'L%'"
LASTNAME
---------------
LUCCHESSI
LUTZ
LEE

appears correct and returns the data but does not have the correct
column heading! The operating system command line processor gets this
long before DB2 does and alters it.

db2 "select lastname as \"Lastname\" from employee where lastname like 'L%'"
Lastname
---------------
LUCCHESSI
LUTZ
LEE

yields exactly the results that are expected.

I stand corrected; my column headings were coming out upper case on the
command line because I had not quoted them correctly.

However, I don't get quite the same results that you did from your two
queries. I am running DB2 V7.2.7 on Windows XP.

Given:
db2 "select lastname as ""Lastname" " from employee where lastname like 'L%'"

I get the following when I execute it on the DB2 command line:
SQL0100N The string constant beginning with ""Lastname from employee where
lastname like 'L%'" does not have an ending string delimiter. SQLSTATE=42603

I can eliminate this error by putting *three* consecutive quotes after the
alias, i.e.
db2 "select lastname as ""Lastname" "" from employee where lastname like
'L%'"

This results in:
Lastname
-----------
LUCCHESSI
LUTZ
LEE

as you predicted.

However, when I execute (on the DB2 command line):
db2 "select lastname as \"Lastname\" from employee where lastname like 'L%'"

I get:
Lastname
-----------
LUCCHESSI
LUTZ
LEE

just as you described.

In any case, the original poster probably knows more now about column
headings that he really wanted to know ;-)

Rhino
Jul 19 '05 #4
Rhino wrote:
However, I don't get quite the same results that you did from your two
queries. I am running DB2 V7.2.7 on Windows XP.

Given:
db2 "select lastname as ""Lastname" " from employee where lastname like
'L%'"

I get the following when I execute it on the DB2 command line:
SQL0100N The string constant beginning with ""Lastname from employee where
lastname like 'L%'" does not have an ending string delimiter.
SQLSTATE=42603

I can eliminate this error by putting *three* consecutive quotes after the
alias, i.e.
db2 "select lastname as ""Lastname" "" from employee where lastname like
'L%'"

This results in:
Lastname
-----------
LUCCHESSI
LUTZ
LEE

as you predicted.

However, when I execute (on the DB2 command line):
db2 "select lastname as \"Lastname\" from employee where lastname like
'L%'"

I get:
Lastname
-----------
LUCCHESSI
LUTZ
LEE

just as you described.

In any case, the original poster probably knows more now about column
headings that he really wanted to know ;-)


You might want to look at the documentation for the DOS command prompt (or
whatever you use) to figure out what it does with the quotes. A Unix
shell, given

"abc \" def"

will pass the following string to the application

abc " def

The DOS command prompt works on the parameters as well somehow, and you have
to counter that to get the " to DB2.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
650
by: Morten Gulbrandsen | last post by:
Hi Programmers, after this legal statement ALTER TABLE EMPLOYEE TYPE =3D InnoDB; I get=20 Warnings: 0 =20 and still MySQL claims to have to use Type =3D MyISAM,
4
11707
by: Thomas Jerkins | last post by:
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 ? Tom
2
10968
by: Irfan Bondre | last post by:
When I try to create a table with a vargraphic column I get the following error. CREATE TABLE EIITEST.IRFAN ("VARC" VARCHAR (48) , "VARGRA" VARGRAPHIC (96) ) DATA CAPTURE NONE IN USERSPACE1; ---------------------------------------------------------------------------- - DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL1216N Graphic...
10
6566
by: Colleyville Alan | last post by:
I am trying to turn a short and fat (63 columns) table into one that is tall and skinny (7 columns). Basically, I am trying to create a "reverse crosstab" using a looping structure in VBA along with SQL. I'd like to take the name of the column and input it into a descritor field. This isn't the table, but will serve as a better illustration than the real deal. If the table looks like this:
3
5773
by: Meena | last post by:
Hi Every Body, I have created a crystal Report and linked to my vb.net forms and working fine, I added more drill drowns in groups everything fine, but What I need is I am not able to display the lables on details section. I have choosen Hide (Drill Down Ok ) For the groups, The details are being displayed when clicked on a group header but how to display label on the details section if I add it, its reflectiong to every line in the...
3
4440
by: appearinggalaxy | last post by:
How can I change the column header text in windows form datagrid? *-----------------------* Posted at: www.GroupSrv.com *-----------------------*
2
3952
by: ricky | last post by:
Hello, If anyone could help me with this I would highly appreciate it. I've tried everything and nothing works. What I am trying to do is so damn basic and it's just frustrating that it seems there's no support for this. Either that or I'm doing something wrong. Well, enough venting, here's what I need. Using this sample XML file (test.xml):
37
4203
by: Jan Wagner | last post by:
Hi, can't figure this one out, what's the CSS way to specify the language? In HTML it would be simply an lang="xx" attribute, or XHTML xml:lang="xx", but, how about in CSS? This would be required for a screen reader (text to speech) for accessibility, to help the reader software use the correct presentation method (e.g. correct language module).
3
1883
by: shawrie | last post by:
Hello everyone can anyone please help me? I basically want to set the length of a string variable to help spacing my simple report out. i tried dim test as string(14) but it didnt like that
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.