Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

want toknow all the object names in a database

 
harjit bedi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
what all i want is what query should i fire to get all the object names like tables,vies etc in a database.
in oracle it is
"select * from cat" or "select * from tab"
but I want to know the exact query for MS-access or SQL-server.
thanks in advance.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest a visit to the Microsoft online documentation to see what they call their system tables.
 
seema kamath
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi harjit,
i think i can try helping u
There is this method called getMetaData() in Connection interface that gives you info about the database. call this method.This returns an object of DatabaseMetaData .
just say,
DatabaseMetaData dmeta= con.getMetaData();
//con in of Connection
The method getTables of DtabaseMetaData gives all the objects associated with a specific database
Say,
ResultSet rs= dmets.getTables(null,null,"%",null)
where the paramter 1 represesnts the schema
2 represents the catalog
3 represents the patterns of table desired
4 represents the types of tables(system,view,general etc
then iterate thru the resultset as usual and using the getSrting(n) where n is the column number get the appropriate name of the object.
this should do.and i hope i have solved your problem
And people,please free to correct me,if i'am wrong.
seema kamath
 
Amit Manurkar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Folks,
First of all thanks a lot for this post of yours, it helped me a lot.
I would like to know if you have any idea about this - I want to query the system tables directly e.g "MSysRelationships" how can I do that ? I tried to query the tables directly using the "executeQuery()" method of the "Statement" object, but it does not allow me to access System tables.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic