Sequences are database objects from which multiple users generate unique integers

Q.  Which is a database objects from which multiple users can generate unique integers?
- Published on 29 Jul 15

a. Views
b. Sequences
c. Synonyms
d. None of the above

ANSWER: Sequences


  • Nirja Shah   -Posted on 30 Sep 15
    - A view is a virtual table based on the result-set.
    - It contains rows and columns, just like a real table.
    - The fields are from one or more real tables in the database.
    - You can add functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from one single table.

    - A synonym is an alias for a schema object.
    - Synonyms can provide a level of security by masking the name and owner of an object and by providing location transparency for remote objects of a distributed database.
    - Also, they are convenient to use and reduce the complexity of SQL statements for database users.
    - Synonyms allow underlying objects to be renamed or moved, where only the synonym needs to be redefined and applications based on the synonym continue to function without modification.

    - Use the CREATE SEQUENCE statement to create a sequence, which is a database object from which multiple users may generate unique integers.
    - You can use sequences to automatically generate primary key values.
    - When a sequence number is generated, the sequence is incremented, independent of the transaction committing or rolling back.
    - If two users concurrently increment the same sequence, then the sequence numbers each user acquires may have gaps, because sequence numbers are being generated by the other user.
    - One user can never acquire the sequence number generated by another user.
    - After a sequence value is generated by one user, that user can continue to access that value regardless of whether the sequence is incremented by another user.
    - Sequence numbers are generated independently of tables, so the same sequence can be used for one or for multiple tables.
    - It is possible that individual sequence numbers will appear to be skipped, because they were generated and used in a transaction that ultimately rolled back.
    - Additionally, a single user may not realize that other users are drawing from the same sequence.
    - After a sequence is created, you can access its values in SQL statements with the CURRVAL pseudocolumn, which returns the current value of the sequence, or the NEXTVAL pseudocolumn, which increments the sequence and returns the new value.

Post your comment / Share knowledge

Enter the code shown above:
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)