如何从JDBC检索序列元数据? [英] How to retrieve sequences metadata from JDBC?

查看:152
本文介绍了如何从JDBC检索序列元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Java代码(使用基本JDBC)检索我的Oracle DB的不同类型的元数据.例如,如果我想检索后缀为_FOO的表的列表,则可以执行以下操作:

I am trying to retrieve different kind of metadata of my Oracle DB from Java code (using basic JDBC). For example, if I want to retrieve the list of tables with _FOO suffix, I can do something like:

Connection connection = dataSource.getConnection();
DatabaseMetaData meta = connection.getMetaData();
ResultSet tables = meta.getTables(connection.getCatalog(), null, "%_FOO", new String[] { "TABLE" });
// Iterate on the ResultSet to get information on tables...

现在,我想从数据库中检索所有序列(例如,所有名为S_xxx_FOO的序列).

Now, I want to retrieve all the sequences from my database (for example all sequence named S_xxx_FOO).

我该怎么做,因为在

How would I do that, as I don't see anything in DatabaseMetaData related to sequences?

我是否必须运行select * from user_sequences之类的查询?

Do I have to run a query like select * from user_sequences ?

推荐答案

您无法通过JDBC API执行此操作,因为某些数据库(仍然)不支持序列.

You can't do this through the JDBC API, because some databases (still) do not support sequences.

获取它们的唯一方法是查询DBMS的系统目录(您提到user_sequences时,我猜是Oracle)

The only way to get them is to query the system catalog of your DBMS (I guess it's Oracle in your case as you mention user_sequences)

这篇关于如何从JDBC检索序列元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆