Link to home
Create AccountLog in
Databases

Databases

--

Questions

--

Followers

Top Experts

Avatar of Axter
Axter🇺🇸

List all tables in a database
What is the SQL command to list all tables in a database?
What is the SQL command to list all columns in a table?

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Pete LongPete Long🇬🇧

What is the SQL command to list all tables in a database?

select * from sysobjects

Avatar of Pete LongPete Long🇬🇧

depends on the link, see syscolumns

Avatar of AxterAxter🇺🇸

ASKER

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?

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of AxterAxter🇺🇸

ASKER

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.

Avatar of MirtheilMirtheil🇺🇸

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.  

Avatar of AxterAxter🇺🇸

ASKER

>>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?

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of MirtheilMirtheil🇺🇸

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')

Avatar of AxterAxter🇺🇸

ASKER

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?

ASKER CERTIFIED SOLUTION
Avatar of MirtheilMirtheil🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of AxterAxter🇺🇸

ASKER

Thanks

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Databases

Databases

--

Questions

--

Followers

Top Experts

Databases are organized collections of data, most commonly accessed through management systems including schemas, tables, queries and processes that allow users to enter and manipulate the information or utilize it in other fashions, such as with web applications or for reporting purposes.