ADSM-L

Re: AW: Select Statement

2001-09-27 12:00:26
Subject: Re: AW: Select Statement
From: Andrew Raibeck <storman AT US.IBM DOT COM>
Date: Thu, 27 Sep 2001 08:56:54 -0700
You don't have to assume, as you can also check the COLUMNS table to see 
the default column ordering. In the case of he VOLUMES table:

select colname, index_keyseq, index_order
   from columns
   where tabname='VOLUMES'

COLNAME                INDEX_KEYSEQ     INDEX_ORDER
------------------     ------------     -----------
VOLUME_NAME                       1     A
VOLUME_NAME                       1     A
STGPOOL_NAME
DEVCLASS_NAME
EST_CAPACITY_MB
PCT_UTILIZED
STATUS
ACCESS
PCT_RECLAIM
SCRATCH
ERROR_STATE
NUM_SIDES
TIMES_MOUNTED
WRITE_PASS
LAST_WRITE_DATE
LAST_READ_DATE
PENDING_DATE
WRITE_ERRORS
READ_ERRORS
LOCATION
CHG_TIME
CHG_ADMIN

This tells you that there is only one indexed column for this table, 
VOLUME_NAME, and that it is sorted in ascending order. Thus the default 
order of the returned records is by volume, so you do indeed need to add 
the "order by" clause if you wished to sort by another column.

Regards,

Andy

Andy Raibeck
IBM Tivoli Systems
Tivoli Storage Manager Client Development
Internal Notes e-mail: Andrew Raibeck/Tucson/IBM@IBMUS
Internet e-mail: storman AT us.ibm DOT com

The only dumb question is the one that goes unasked.
The command line is your friend.
"Good enough" is the enemy of excellence.




"Baines, Paul" <Paul.Baines AT PARTNER.COMMERZBANK DOT COM>
Sent by: "ADSM: Dist Stor Manager" <ADSM-L AT VM.MARIST DOT EDU>
09/27/2001 08:22
Please respond to "ADSM: Dist Stor Manager"

 
        To:     ADSM-L AT VM.MARIST DOT EDU
        cc: 
        Subject:        AW: Select Statement

 

I learnt you should never assume the ordering with SQL and always qualify
it:

Select volume_name,last_read_date from volumes order by last_read_date

or in descending order

Select volume_name,last_read_date from volumes order by last_read_date 
desc


Mit freundlichen Grüßen - With best regards
Serdeczne pozdrowienia - Slan agus beannacht
Paul Baines
TSM/ADSM Consultant


<Prev in Thread] Current Thread [Next in Thread>