SEQUENCE is an SQL-standard out-of-transactions ID source, that provides for multi-threading inserts into the same table without duplication of unique IDs. In some servers, matured before this SQL standard was adopted, there can be different names for the feature (like GENERATOR in Firebird/Interbase/Yaffil lineup) or different mechanism (like auto-inc fields in MySQL)
Questions tagged [sequence-sql]
20 questions
18
votes
4 answers
Oracle Sequence Transactionality
I need for a particular business scenario to set a field on an entity (not the PK) a number from a sequence (the sequence has to be a number between min and max
I defined the sequence like this :
CREATE SEQUENCE MySequence
MINVALUE 65536
…

Cris
- 4,947
- 6
- 44
- 73
6
votes
1 answer
Sequence must have same owner as table it is linked to
have following sql, got error in last line, ERROR: sequence must have same owner as table it is linked to [Failed SQL: (0) ALTER SEQUENCE test_table_seq OWNED BY test_table.id
CREATE SEQUENCE test_table_seq;
ALTER TABLE test_table ALTER COLUMN id…

user8355591
- 181
- 1
- 10
5
votes
1 answer
In Netezza I'm trying to use a sequence in a case statement but the sequence value doesn't increment
Here is the sequence creation syntax used:
CREATE SEQUENCE BD_ID_SEQ AS INTEGER
START WITH 999
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
NO CYCLE;
I have a table with the following values…

user3254441
- 51
- 1
- 2
3
votes
1 answer
How to grant usage on generator syntax
I'm usually not the one working with Firebird language, but I have to fix access to generators in order to continue working. There is one line in my script: set generator order_gen to 0 that doesn't work anymore.
I'm trying: GRANT USAGE ON GENERATOR…

MHeydt
- 135
- 8
3
votes
1 answer
Entity Framework Code First and SQL Server 2012 Sequences
I was in the middle of implementing a database audit trail whereby CRUD operations performed through my controllers in my Web API project would serialize the old and new poco's and store their values for later retrieval (historical, rollback,…

James Legan
- 1,903
- 2
- 14
- 21
2
votes
1 answer
Sequence function in Amazon Athena
I am not able to use the sequence function amazon athena.
It shows a syntax error saying : Not a window function: sequence
I wrote the following code :
SELECT sequence(1, 1) OVER () as seq_num
FROM

user21164800
- 21
- 1
2
votes
1 answer
Handling auto inc columns in Oracle via slick
I am using slick 2.1.0. Oracle doesn't have a notion of auto increment attribute for a column, so how can I manage an insert via slick using a sequence.
e.g. I have a table & sequence as follows :
CREATE TABLE USER
( "USER_ID" NUMBER…

Rohan
- 69
- 5
1
vote
2 answers
Create a serial number using characters and sequential number in PostgreSQL
I would like to create a serial number/code that looks something like
22LX346789.
The left 2 digits representing the year (of manufacture/registration), the 2 characters indicate product type. The right numbers increment, and not required to reset…

Ray Connon
- 13
- 3
1
vote
1 answer
Database sequences -- Oracle golden gate bi-directional replication
I have a golden gate BI-Directional replication setup which is working fine,
But i am looking to create database sequences in ODD-EVEN distribution on both sites as explained something like here ---…

Damon
- 21
- 4
1
vote
4 answers
Pass SELECT MAX(`Id`) FROM Table to setval()
I want to pass (SELECT MAX(Id) FROM Table to mariadb's setval() function I tried with:
SELECT setval(`MySequence`, (SELECT MAX(`Id`) FROM `Table`));
but it doesn't work, I also tried:
SET @max_value = (SELECT MAX(`Id`) FROM `Table`);
SELECT…

Pablo Recalde
- 3,334
- 1
- 22
- 47
1
vote
1 answer
Possible to make a query-able counter using Postgres sequence and Hibernate mapping?
I'm getting the "No data type for node" error when I run this query:
session.createQuery("select nextval( 'next_num_seq' )")
which I know means that I need to make it a property of a class, but I haven't been able to find a way to add a sequence to…

user3413468
- 247
- 1
- 3
- 9
1
vote
1 answer
In Postgresql, Sequence numbers set to start at 1, but is actually returning new records with id of 2?
Using setval('sequence',1) sets the start value of the sequence to 1. But when a record is inserted, the first 'sequence' number is actually 2.
How do I get the actual first record to have a sequence number of 1?

Alan Wayne
- 5,122
- 10
- 52
- 95
1
vote
1 answer
sequence already created but error showing RA-02289: sequence does not exist
I created a sequence in ORACLE 10g database
CREATE SEQUENCE "test_seq"
START WITH 1 INCREMENT BY 3
NOMAXVALUE NOMINVALUE NOORDER NOCYCLE NOCACHE;
I also have a table in database to use this sequence
CREATE TABLE USER_TEST
(
U_NAME VARCHAR2…

Anand
- 114
- 1
- 2
- 14
0
votes
1 answer
Creating a trigger and sequence to create a new primary key
How can I write a sequence and trigger that upon insert into a table will check if the ID attribute (and INTEGER) is null.
If null it should increment through from 1 upwards checking if the value itself if already a primary key and if not that…

Joe Moore
- 15
- 3
0
votes
1 answer
Is it a bad idea using a single sequence generator in PostgreSQL?
This is a generic question about PostgreSQL sequence performance, for if they could be a bottleneck in high-write-concurrency databases, when choosing use one instead of one per table.
I outlined performance and bottleneck because I am perfectly…

coterobarros
- 941
- 1
- 16
- 25