What will be the output of the following Snowflake SQL commands?
CREATE SEQUENCE seq_test START = 5 INCREMENT = 3; SELECT seq_test.nextval AS val1; SELECT seq_test.nextval AS val2;
Choose the correct pair of values returned by the two SELECT statements.
CREATE SEQUENCE seq_test START = 5 INCREMENT = 3; SELECT seq_test.nextval AS val1; SELECT seq_test.nextval AS val2;
Remember the sequence starts at 5 and increments by 3 each time nextval is called.
The sequence starts at 5, so the first nextval returns 5. The second nextval adds the increment 3, returning 8.
You want to create a sequence in Snowflake that starts at 1, increments by 1, and stops generating values after reaching 10. Which CREATE SEQUENCE statement correctly enforces this behavior?
To stop the sequence after reaching the max value, cycling must be disabled.
Setting MAXVALUE to 10 limits the sequence to 10. CYCLE = FALSE prevents it from restarting after reaching max.
You have a Snowflake table receiving inserts from multiple distributed clients simultaneously. You want to assign unique IDs automatically without conflicts or gaps. Which approach is best?
Snowflake sequences are designed to handle concurrent access safely.
A single Snowflake sequence guarantees unique, ordered IDs even with concurrent clients, avoiding conflicts and gaps.
Which Snowflake privilege must a user have to be able to use NEXTVAL on a sequence?
Check which privilege allows using sequence values without changing ownership.
The USAGE privilege allows a user to call NEXTVAL on a sequence without needing ownership.
Consider this Snowflake sequence:
CREATE SEQUENCE seq_cycle START = 1 INCREMENT = 2 MAXVALUE = 7 CYCLE = TRUE;
What will be the sequence of values returned by five consecutive calls to NEXTVAL?
CREATE SEQUENCE seq_cycle START = 1 INCREMENT = 2 MAXVALUE = 7 CYCLE = TRUE; SELECT seq_cycle.nextval; SELECT seq_cycle.nextval; SELECT seq_cycle.nextval; SELECT seq_cycle.nextval; SELECT seq_cycle.nextval;
With CYCLE enabled, the sequence restarts after reaching MAXVALUE.
The sequence starts at 1, increments by 2: 1,3,5,7. After 7 (max), it cycles back to start at 1 again.