Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

List all tables in a database

Posted on 2005-03-17
10
Medium Priority
?
33,537 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
  • 5
  • 3
  • 2
10 Comments
 
LVL 58

Expert Comment

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

select * from sysobjects
0
 
LVL 58

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Exchange database can often fail to mount thereby halting the work of all users connected to it. Finding out why database isn’t mounting is crucial and getting the server back online. Stellar Phoenix Mailbox Exchange Recovery is a champion product t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
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…
Suggested Courses

580 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