sql 如下:
select sequence_name from user_sequences where sequence_name= '参数'
需要注意的是 Oracle sequence 参数必须转换成大写。
例子:(这是使用simple 框架实现)
// 判断 oracle sequence 是否已经存在
public static boolean isSequenceExists(final DataSource dataSource, final String sequencename)
throws SQLException {
final JdbcTemplate jt = new JdbcTemplate(dataSource);
return jt.execute(new ConnectionCallback() {
@Override
public Boolean doInConnection(final Connection con) throws SQLException {
String sql = "select sequence_name from user_sequences where sequence_name= '"+sequencename.toUpperCase()+"'";
ResultSet rs= con.prepareStatement(sql).executeQuery();
if(rs.next()){
return true ;
}else {
return false;
}
}
});
}