Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrieve all the tables from a database

 
sunita shaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell me how to retrieve all the table names from a database in microsoft access . dont tell me select * from table name coz this is just to retrieve the fields of a particular table .
 
Nilesh Pereira
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I'm not going to tell you to select * from table
You need to get the DatabaseMetaData from the database by calling getMetaData() in Connection. Then all you need to do is call getTables(...) in DatabaseMetaData to get the list of tables.
 
sunita shaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi! nilesh
thanx for the help but i still havent got it ..can u let me know exactally how do do it.do u have some coding or something.hope u got my problem well.
i.e i want a query in Ms Access 2000 for retrieving the names of the table not a query that will run in SQL server only.
please reply back soon.
 
Nilesh Pereira
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sunita
You can refer DatabaseMetaData for more information.
The code should look something like this:

[ April 21, 2003: Message edited by: Nilesh Pereira ]
 
Bheemeswara Rao Amruthavakkula
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Neelesh code works fine but it will return system tables and views also in addition to the table names. replace the following line in the Neelesh code to get only the table names
ResultSet rs = dmd.getTables(null, null, null, new String[]{"TABLE"});
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic