我无权查看数据库,但我可以创建数据库对象(通过 xml 文件)。 xml 文档说,如果我将名为“identity”的属性设置为 true,则会创建一个序列。我是否可以编写返回序列名称的逻辑,以便在编写 INSERT 语句时可以使用 nextVal?
罗伯特
这是 documentation , 查找“身份”一词...
最佳答案
如果您可以运行 select 语句,那么您也许可以尝试 select * from user_sequences 来获取序列的名称。否则,您能否发送您正在使用的此数据库创建实用程序的文档(如果它是公开的)。否则很难回答这个问题。
编辑:
在查看文档后,它说如果您创建一个带有主键的表,它将创建一个具有以下规则的序列,直接引用文档:
Primary keys must contain one columnref subelement that includes a single attribute, name, that references the column name to include in the primary key. In SQL Server, the key is mapped as an identity field with an auto-incremented value. On Oracle, a sequence is automatically created with the table name plus _seq suffix.
因此,您的查询将是:
select * from all_sequences where sequence_name = upper(tablename || '_SEQ');
关于java - 获取序列名称(Oracle)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5560747/