If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > List all tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-15-06, 10:56
stanislav.ondac stanislav.ondac is offline
Registered User
 
Join Date: Aug 2005
Posts: 140
List all tables

Hi all
how can I list all tables in all databases in one step (select) ?
I tried something with sysmaster database and systabnames table but not successfull,because there are indexes too.

Thanks
Reply With Quote
  #2 (permalink)  
Old 08-15-06, 11:42
ifx ifx is offline
Registered User
 
Join Date: Feb 2005
Posts: 33
Maybe this could be your solution
(number of columns > 0 seems to be a right approach to find only tables,
but I didn't verified it completely, so no guarantee,
probably there's a better way):

select * from systabnames, systabinfo
where partnum=ti_partnum and ti_ncols>0

Best regards
ifx
Reply With Quote
  #3 (permalink)  
Old 08-15-06, 14:55
stanislav.ondac stanislav.ondac is offline
Registered User
 
Join Date: Aug 2005
Posts: 140
But ti_ncols in systabinfo(view of the sysptnhdr) and ncols in sysptnhdr are only number of varchar and blob columns (not all columns) in the table.
Reply With Quote
  #4 (permalink)  
Old 08-15-06, 16:04
ifx ifx is offline
Registered User
 
Join Date: Feb 2005
Posts: 33
You are right,
"ti_ncols>0" doesn't return all tables.

I received a "bit better result" with the following statement,
but there are still some system tables missing
and I am not sure, if "ti_nkeys=0" doesn't return too much entries.
"bitval(ti_flags, "0x0020")<>1" should exclude temptables.

-- database sysmaster
select * from systabnames, systabinfo
where partnum=ti_partnum
and (ti_ncols>0 or ti_nkeys=0 or ti_nrows>0)
and bitval(ti_flags, "0x0020")<>1

I don't have any more ideas to that problem
because I cannot find differences between the missing system tables
and some of the index tables.
Maybe you have to join to the systables of each database.
Good luck.

Best regards
ifx
Reply With Quote
  #5 (permalink)  
Old 08-16-06, 01:54
sysmaster sysmaster is offline
Registered User
 
Join Date: Mar 2006
Posts: 15
oncheck -pe > all_tab.txt
Reply With Quote
  #6 (permalink)  
Old 08-16-06, 12:54
blackguard blackguard is offline
Registered User
 
Join Date: Sep 2002
Posts: 102
If you explain your purpose, I might be able to help you.
Reply With Quote
  #7 (permalink)  
Old 08-16-06, 13:10
stanislav.ondac stanislav.ondac is offline
Registered User
 
Join Date: Aug 2005
Posts: 140
My only purpose is to find out, if it is possible to list all user tables(with some additional informations like table name, number of rows) using only sysmaster database(or another one step solution) - not with joining systables in every database.
Reply With Quote
  #8 (permalink)  
Old 08-16-06, 13:11
artemka artemka is offline
Registered User
 
Join Date: May 2004
Location: New York
Posts: 248
you know the names of all your databases, you can try something like

create a file with the names of the databases

db1
db2
etc..

for i in `cat dbfilename`
do
dbaccess $i <<!! >> tablenames
select tabname from systables where tabid > 99
!!
done
Reply With Quote
  #9 (permalink)  
Old 08-17-06, 01:33
sysmaster sysmaster is offline
Registered User
 
Join Date: Mar 2006
Posts: 15
Quote:
Originally Posted by stanislav.ondac
My only purpose is to find out, if it is possible to list all user tables(with some additional informations like table name, number of rows) using only sysmaster database(or another one step solution) - not with joining systables in every database.
Did you use oncheck -pe?
Reply With Quote
  #10 (permalink)  
Old 08-17-06, 07:16
stanislav.ondac stanislav.ondac is offline
Registered User
 
Join Date: Aug 2005
Posts: 140
Quote:
Originally Posted by sysmaster
Did you use oncheck -pe?
No I didnt, because oncheck -pe returns also indexes.
And I need only regular tables.
Reply With Quote
  #11 (permalink)  
Old 08-17-06, 10:49
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
I would follow artemka's solution Stanislav, just query the present databases systables table. For a list of present databases you could query the sysmaster database. And for the individual systables queries you could do a refinement with:
Code:
dbaccess $i <<!!
SELECT tabname FROM systables WHERE tabid > 99 AND tabtype = 'T'
!!
which produces a list of only user tables. In an application or script you can easily combine all these queries of course...

Regards
Reply With Quote
  #12 (permalink)  
Old 01-18-07, 05:10
adelxp adelxp is offline
Registered User
 
Join Date: Nov 2006
Posts: 3
SELECT tabname FROM systables WHERE tabid > 99
Reply With Quote
  #13 (permalink)  
Old 01-19-07, 03:39
stanislav.ondac stanislav.ondac is offline
Registered User
 
Join Date: Aug 2005
Posts: 140
This select lists only tables for currrent database.
I think there is no way to list tables from all databases in one select.
Reply With Quote
  #14 (permalink)  
Old 01-29-07, 15:06
anurbas anurbas is offline
Registered User
 
Join Date: Dec 2006
Location: Latrobe, PA
Posts: 16
If your looking for all tables in all databases with using one select statement from the sysmaster table then no, you will not get your information. You have to use a join.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On