Search code examples
databasejdbcsequencesequences

get schema name


can some one pls tell me how to get the 'schema name' for a particular 'sequence' using jdbc


Solution

  • I assume you are using Oracle DB.
    If that's the case you can run the query given below via JDBC and get the column named sequence_owner for the Schema Name to which a sequence belongs to.

    SELECT sequence_owner
      FROM all_sequences
     WHERE sequence_name = '<YOUR_SEQUENCE_NAME>'