Fine-grained access control for sequences

This page explains howfine-grained access control works withSpanner sequences for GoogleSQL-dialect databases and PostgreSQL-dialect databases.

For fine-grained access control users, you can grant either one or both of thefollowing privileges to allow access to read sequence information orgenerate values from the sequence.

  • GrantSELECT on the sequence to allow read access to the parametersand current state of the sequence.

    GoogleSQL

    GRANTSELECTONSEQUENCESEQUENCE_NAMETOROLEROLE_NAME;

    PostgreSQL

    GRANTSELECTONSEQUENCESEQUENCE_NAMETOROLE_NAME;
  • GrantUPDATE on the sequence to allow calls to the sequence valuegenerator.

    GoogleSQL

    GRANTUPDATEONSEQUENCESEQUENCE_NAMETOROLEROLE_NAME;

    PostgreSQL

    GRANTUPDATEONSEQUENCESEQUENCE_NAMETOROLE_NAME;

Required privileges for sequence operations

The following table contains details about which privileges you require whenperforming a specific sequence operations.

OperationPrivilege requirements

GoogleSQL:

GET_NEXT_SEQUENCE_VALUE()

PostgreSQL:

nextval()

Requires anUPDATE orSELECT privilege on the sequence. Note that if you execute this function through generated columns or default values, you also need to have anINSERT orUPDATE privilege on the column. AnUPDATE privilege on a sequence doesn't automatically grant any privilege on the columns where you want to use the sequence.

GoogleSQL:

GET_INTERNAL_SEQUENCE_STATE()

PostgreSQL:

spanner.get_internal_sequence_state()

Requires theSELECT privilege on the sequence that you request.

GoogleSQL:

INFORMATION_SCHEMA.SEQUENCES
INFORMATION_SCHEMA.SEQUENCE_OPTIONS

PostgreSQL

INFORMATION_SCHEMA.SEQUENCES

You can have theSELECT orUPDATE privilege on the sequence you want to query. You can only see the sequences that you have a privilege to view.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.