• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

want toknow all the object names in a database

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest a visit to the Microsoft online documentation to see what they call their system tables.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic