Skip to main content

SQL Question

Submitted by Kane on

Just a question for the SQL users out there. Is it possible to find the count of how many tables are in a database?

If I can get this question answered, then my Software Design assignment will be finished! =D

Submitted by mcdrewski on Tue, 04/10/05 - 11:33 PMPermalink

Yes, it's possible. It depends (however) on the database you're using.

Most databases (AFAIK all, but I'm sure there's an exception somewhere) use meta-tables to hold information about their tables and columns.

In oracle, it's SYS.ALL_TABLES (or it's kin SYS.USER_TABLES / SYS.DBA_ALL_TABLES - refer to Oracle Table Reference for more versions)
In SQLServer, it's DBO.SYSOBJECTS

There is *no* standard for this though, so every database is different.
However, though ODBC,JDBC,DAO etc there are calls in the API to enumerate the tables. Each driver implements this in a DB-specific fashion to hide the underlying implementation.

Without wanting to sound facetious though, asking an "is it possible" question in a software engineering assignment is just asking for trouble. ie: Is it possible to access the "hot coffee" scenes in GTA:SA? Easy, intended or supported, no. Possible, well obviously.

Submitted by Kane on Tue, 04/10/05 - 11:58 PMPermalink

Ok let me be a little more specific then... =D

How do I find the number of tables in a PostgreSQL database using JDBC? I am totally stuck, I've Googled it and can't find anythiung. =(

Submitted by redwyre on Wed, 05/10/05 - 1:35 AMPermalink

A java link flew out of your nose? How fitting ;)

Submitted by mcdrewski on Fri, 07/10/05 - 8:13 AMPermalink

Did you manage to solve this one Kane? Happy to explain further if you want...

Submitted by Kane on Mon, 10/10/05 - 8:55 AMPermalink

I did manage to figure something out, it most definately wasn't the best way to do things but it worked... [:p]

I would post the code I wrote but I think everyone would throw up all over their keyboards [;)]

Thanks for ur help mcdrewski!

Posted by Kane on

Just a question for the SQL users out there. Is it possible to find the count of how many tables are in a database?

If I can get this question answered, then my Software Design assignment will be finished! =D


Submitted by mcdrewski on Tue, 04/10/05 - 11:33 PMPermalink

Yes, it's possible. It depends (however) on the database you're using.

Most databases (AFAIK all, but I'm sure there's an exception somewhere) use meta-tables to hold information about their tables and columns.

In oracle, it's SYS.ALL_TABLES (or it's kin SYS.USER_TABLES / SYS.DBA_ALL_TABLES - refer to Oracle Table Reference for more versions)
In SQLServer, it's DBO.SYSOBJECTS

There is *no* standard for this though, so every database is different.
However, though ODBC,JDBC,DAO etc there are calls in the API to enumerate the tables. Each driver implements this in a DB-specific fashion to hide the underlying implementation.

Without wanting to sound facetious though, asking an "is it possible" question in a software engineering assignment is just asking for trouble. ie: Is it possible to access the "hot coffee" scenes in GTA:SA? Easy, intended or supported, no. Possible, well obviously.

Submitted by Kane on Tue, 04/10/05 - 11:58 PMPermalink

Ok let me be a little more specific then... =D

How do I find the number of tables in a PostgreSQL database using JDBC? I am totally stuck, I've Googled it and can't find anythiung. =(

Submitted by redwyre on Wed, 05/10/05 - 1:35 AMPermalink

A java link flew out of your nose? How fitting ;)

Submitted by mcdrewski on Fri, 07/10/05 - 8:13 AMPermalink

Did you manage to solve this one Kane? Happy to explain further if you want...

Submitted by Kane on Mon, 10/10/05 - 8:55 AMPermalink

I did manage to figure something out, it most definately wasn't the best way to do things but it worked... [:p]

I would post the code I wrote but I think everyone would throw up all over their keyboards [;)]

Thanks for ur help mcdrewski!