Get Tabes Names in A Database

  • Thread starter Thread starter Ricardo Luceac
  • Start date Start date
Ricardo,

That depends on the database you are using. There are a number of
things that you can do to get this.

If you need to do it across multiple database types, then you should use
ADOX, which is the COM component distributed with ADO. This allows you to
pass a connection and get schmea information in a consistent way.

In .NET 2.0 and above, you can call the GetSchema method on the
DbConnection class (all connection classes should derive from this class) to
get schema information from your database.

Then, you can usually query the database for this information. For
example, you can use INFORMATION_SCHEMA on Sql Server 2005 and above, or
just run a query against sysobjects where the xtype field = 'U' (for user
table).

Hope this helps.
 
Depends on the DB you are using... in Oracle I believe the syntax is:

SELECT table_name FROM user_tables

While in MS SQL...

SELECT name FROM sysobjects WHERE type = 'U'

I could be wrong though as it’s been quite a while since I did much of
anything with either.

Brendan
 
After a bit of digging through the Openbase documentation, it looks like
table info is stored in _syste_tables, so a query of:

SELECT tablename FROM _sys_tables

should give you a list of the table names.

Brendan
 
Back
Top