Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements

GRANT USAGE ON SEQUENCE statement

Grants privilege to use a specified sequence.

Syntax
GRANT USAGE ON SEQUENCE sequence-name 
TO userid, ...
Remarks

This privilege allows the user to select the current or next value from the specified sequence.

Privileges

You must have the MANAGE ANY OBJECT PRIVILEGE privilege.

Side effects

Automatic commit.

Standards
  • ANSI/ISO SQL Standard

    Part of optional ANSI/ISO SQL Language Feature T176.

Example

A ticketing application creates a sequence to ensure that each ticket has an unique number.

CREATE SEQUENCE TicketNumber
   MINVALUE 1000
   MAXVALUE 100000;

A user, TicketAgent, using this application to generate tickets must be granted the usage rights to the sequence so that they can select values from the sequence.

GRANT USAGE ON SEQUENCE TicketNumber to TicketAgent;

Now, TicketAgent can select values from the TicketNumber sequence and use them to create new tickets. For example:

INSERT INTO NewTicket
   SELECT TicketNumber.nextval, 'Concert Ticket', ...;