This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Fetch all constraints, schema name through java code from oracle database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Fetch all constraints, schema name through java code from oracle database " Watch "Fetch all constraints, schema name through java code from oracle database " New topic
Forums: JDBC and Relational Databases Oracle/OAS
Author

Fetch all constraints, schema name through java code from oracle database

Ankit Kr Sah
Greenhorn

Joined: Feb 19, 2013
Posts: 4
I want some samples of code to fetch all constraints schema name right now i can get table names, number of columns in table, their datatype and name of columns through resultsetmetadeta need code some what like this
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 2074
    
  20

"I want doesn't get" as my Mum used to say...

Oracle provides a lot of database catalogue views such as ALL_CONSTRAINTS that will give you a vast amount of information about your database objects, provided you have access to them (talk to your DBA).

I suggest you do the following:

  • Figure out what specific information you actually need.
  • Figure out which DB catalogue views you need to look at in order to find this information.
  • Write the SQL to fetch that information from the relevant DB catalogue views.
  • Test your SQL on the database using your SQL interpreter (e.g. SQL*Plus or SQL Developer) with the appropriate user.
  • Then decide how you want to be able to access this data in future, and write a program to run the SQL as necessary.

  • If you try these things out but still have difficulties, come back and ask for help with a specific problem.

    No more Blub for me, thank you, Vicar.
    Martin Vajsar
    Sheriff

    Joined: Aug 22, 2010
    Posts: 3704
        
      61

    While it should be possible to get a lot of info using DatabaseMetaData, I'd also opt for the catalogue views in Oracle.

    Just a nitpick:
    chris webster wrote:... provided you have access to them (talk to your DBA).

    I always had the impression that ALL_* views are always available - they describe objects the user has been granted access to. Isn't it the case?
    chris webster
    Bartender

    Joined: Mar 01, 2009
    Posts: 2074
        
      20

    Martin Vajsar wrote:Just a nitpick:
    chris webster wrote:... provided you have access to them (talk to your DBA).

    I always had the impression that ALL_* views are always available - they describe objects the user has been granted access to. Isn't it the case?

    Sorry - you're right of course. I was thinking about all the other DBA-views that may not necessarily be visible to the user. I think I've been permanently scarred by my last project working on a site where the DB was so totally locked down that the Oracle developers were lucky if they could query DUAL!
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Fetch all constraints, schema name through java code from oracle database