db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajesh Kartha <karth...@gmail.com>
Subject Re: IRC chat summary: is there a way to find out column names in ij?
Date Fri, 07 Jul 2006 17:50:59 GMT
Daniel John Debrunner wrote:

>Knut Anders Hatlen wrote:
>
>  
>
>>"Jean T. Anderson" <jta@bristowhill.com> writes:
>>
>>
>>    
>>
>>>A user asked this question on #derby today (and here's a summary of the
>>>chat since there are probably others on this list with the same question):
>>>
>>>  Is there a way that I can find out what columns are in a table in ij?
>>>  like describe tablename or something?
>>>
>>>You can't do that in ij, but that feature has been logged as DERBY-1164.
>>>      
>>>
>>Well, actually, you *can* do that in ij, but it's not very user
>>friendly. You could write a query against the system tables. To find
>>out what columns are in SYS.SYSCONSTRAINTS, enter this query:
>>
>>  select columnnumber, columnname, columndatatype
>>    from sys.systables t, sys.syscolumns, sys.sysschemas s
>>    where tableid=referenceid and t.schemaid=s.schemaid
>>      and schemaname='SYS' and tablename='SYSCONSTRAINTS'
>>    order by columnnumber;
>>
>>    
>>
>
>Or if you just want the column names:
>
>select * from MYTABLE where 1 = 0
>
>Dan.
>
>
>  
>
Although I did notice  with the simpler approach of  'select * from 
mytable where 1=0',  longer column names does not show up in its entirety:

ij> create table abcd (id int, alongcolumnname char(2), 
amuchlongercolumnname char(4));
0 rows inserted/updated/deleted
ij> select * from abcd where 1=0;
ID         |ALO&|AMU&
---------------------

0 rows selected
ij> select columnnumber, columnname, columndatatype from sys.systables 
t, sys.syscolumns, sys.sysschemas s where tableid
=referenceid and t.schemaid=s.schemaid and schemaname='APP' and 
tablename='ABCD' order by columnnumber;
COLUMNNUMB&|COLUMNNAME
                    |COLUMNDATATYPE
------------------------------------------------------------------------------------------------------------------------
------------------------------------
1          |ID
                    |INTEGER
2          |ALONGCOLUMNNAME
                    |CHAR(2)
3          |AMUCHLONGERCOLUMNNAME
                    |CHAR(4)

3 rows selected

-Rajesh


Mime
View raw message