简体   繁体   中英

Get Sequence Name (Oracle)?

I don't have access to see the database, but I have the ability to create database objects (via an xml file). The xml documentation says that if I set an attribute called "identity" to true then a sequence will be created. Is it possible for me to write logic that would return the name of the sequence so that I can use nextVal when I'm writing INSERT statements?

Robert

Here's the documentation , do a find on the word "identity"...

If you can run select statements, then you might be able to try select * from user_sequences to get the names of sequences. Otherwise, could you please send the documentation for this database creation utility that you are using, if it is public. Otherwise, it will be very difficult to answer this question.

EDIT:

After a review of the documentation, it said that if you created a table with a primary key, it would create a sequence with the following rules, quoted directly from the documentation:

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.

Thus, your query would be:

select * from all_sequences where sequence_name = upper(tablename || '_SEQ');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM