aspose file tools*
The moose likes JDBC 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
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 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: 1475
    
  11

"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: 3429
        
      47

    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: 1475
        
      11

    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!
     
     
    subject: Fetch all constraints, schema name through java code from oracle database
     
    Similar Threads
    Looking for some opinions on how to write effective XML
    Schema and Database
    DatabaseMetaData API
    Adding new Entity Bean in the existing application
    select * vs select column1,column2 ..