?
Solved

List all tables in a database

Posted on 2005-03-17
10
Medium Priority
?
33,303 Views
Last Modified: 2013-12-25
What is the SQL command to list all tables in a database?
What is the SQL command to list all columns in a table?
0
Comment
Question by:Axter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 57

Expert Comment

by:Pete Long
ID: 13565359
What is the SQL command to list all tables in a database?

select * from sysobjects
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 13565379
depends on the link, see syscolumns
0
 
LVL 30

Author Comment

by:Axter
ID: 13565388
Is the above SQL command unique to Btrieve?

If so, is there a command that is more general, and would apply to most database types?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Author Comment

by:Axter
ID: 13565417
I'm writing a program that is suppose to work with both IBM UDB, Btrieve, and Pervasive SQL.

So I'm looking for commands that will work with all threee database types.

I just tried sysobjects on IBM UDB, and it failed.
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 13568047
It would also fail on Pervasive. For Pervasive to get the list of table name, you would use:
select xf$name from x$file
THen to list the columns in a table you would use:
SELECT xf$name, xe$name FROM "X$Field", x$file where xe$file = xf$id group by xf$name, xe$name
You can safely disregard any columns that start with "NN_" and have a datatype of 227.  
0
 
LVL 30

Author Comment

by:Axter
ID: 13568097
>>select xf$name from x$file

Is xf$name a constant in above command?

Do I replace "file" with the name of a file?

Do you have any good links with more info?

I notice there's no Pervasive SQL topic area.
Does Pervasive SQL use BTrieve as part of it's DB engine?
Are they associated with each other some how?
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 13568189
Pervasive.SQL is the current version of Btrieve.  "xf$name" is the name of the column in the system table X$FILE (you can double click it within the PCC and see what's all's there).  
To get a list of columns for a specific table, you'd need to look up the table name in the X$FILE to get the XF$ID which is in the X$FIELD table as XE$FILE column.  So for example:
select XE$NAME from X$FIELD where XE$FILE = (select XF$ID from X$FILE where XF$NAME = 'myTableName')
0
 
LVL 30

Author Comment

by:Axter
ID: 13568237
So just to verify, the following EXACT command will list all the tables?
select xf$name from x$file

So the commands that PeteLong posted will not work on Btrieve.  Is that correct?
0
 
LVL 18

Accepted Solution

by:
mirtheil earned 2000 total points
ID: 13568442
Correct. To list all tables (including system tables) use: select xf$name from x$file
The commands Petelong will not work with Pervasive.
0
 
LVL 30

Author Comment

by:Axter
ID: 13568462
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question