Questions tagged [database-sequence]

A database sequence is a number generator that produces unique numbers in a scalable and concurrency safe way.

A database sequence is a number generator that produces unique numbers in a scalable and concurrency safe way.

Once a sequence value has been generated, this number is never re-used (unless a sequence is defined to have a maximum value and cycle through its possible range).

Sequence values are not guaranteed to be gapless but offer a scalable and fast way to generate unique numbers even in high concurrency situations.

Sequences are supported by nearly all modern DBMS. However, the syntax to create them and to obtain a number from them differs between the DBMS products.

106 questions
0
votes
1 answer

Consuming sequence inside a embeddedId in springboot

I have the next issue -> I have a table on my db with a composite id... Supose (Id1,Id2,Id3,Id4), the Id4 is generated by a sequence on the db... My question is, in spring boot, I generate the entity 'Table1' and the corresponding 'Table1Id', but…
0
votes
1 answer

PostgreSQL column to keep track of number of appearances of a certain kind

I have to make a new column inside of an already existing database that keeps track of the number of occurences of a certain kind. Here's an example to be more clear: id | eqid | etcd | this would be my new column ------------------------- 1 | 4 …
0
votes
1 answer

Postgres sequence that resets once the id is different

I am trying to make a Postgres sequence that will reset once the id of the item it is linked to changes, e.g: ID SEQUENCE_VALUE 1 1 2 1 1 2 1 3 2 2 3 1 I don't know…
0
votes
2 answers

Spring Boot entity with Pk using Oracle DB Sequence in a trigger

I need a help on persisting an entity in a Oracle DB table that uses trigger and sequence for PK. By now, I tried these from other stackoverflow questions: @Id @GeneratedValue(generator="increment") @GenericGenerator(name="increment",…
0
votes
1 answer

Sequence id is not properly inserted

I have created a sequence but its not inserting ids in sequence order. For Ex: First I have created one set of record seq number generated as 1, 2, 3, 4 Again I have created another set of records seq started from 8, 9, 10 For 3rd time I have…
Abinnaya
  • 203
  • 4
  • 26
0
votes
2 answers

2 Applications using different hibernate versions but same oracle database throwing unique constraint error

There are 2 applications : one is using Spring boot - 1.5.18.Release version, which has hibernate version as 5.0.12.Final :https://search.maven.org/artifact/org.springframework.boot/spring-boot-dependencies/1.5.18.RELEASE/pom and another application…
0
votes
1 answer

SERIAL PRIMARY KEY keeps counting when the csv importing file fails in pgAdmin

I have table with SERIAL PRIMARY KEY and when importing csv file with some data and it fails for any reason, when importing successes the PRIMARY KEY instead of starting from zero (in case the table was empty) it starts from the number that it was…
Julio
  • 175
  • 1
  • 17
0
votes
0 answers

Sequence is incremented even if no INSERT occurs

I've a table with following structure: CREATE TABLE web.cabinet_account_section ( id serial NOT NULL, section_id text NULL, account_id int4 NULL, cabinet_param_id int4 NULL, CONSTRAINT cabinet_account_section_pkey PRIMARY KEY…
funnelCONN
  • 149
  • 1
  • 11
0
votes
0 answers

How to declare a function with a select statement to reset all auto_increment values to max id of the tables in postgresql

I have a Postgres database with many tables. I want to declare a function that reset all auto_increment values (next_value) of all the tables to max(id) of the table. For example, if max(id) of sample_table is 22: postgres=# SELECT MAX(id) + 1 FROM…
Mohsen Abasi
  • 2,050
  • 28
  • 30
0
votes
1 answer

Postgres tech role for sequence only

There is role sequence_owner. This is special tech role for working with sequence only. create role sequence_owner; GRANT sequence_owner TO administrator; GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA schema1 TO sequence_owner; Also there…
yazabara
  • 1,253
  • 4
  • 21
  • 39
0
votes
1 answer

Postgresql sequencer not found

I'm creating an item record number generator. The goal is to have a table to house all record number/sequencers for a variety of different types. For example, for a "Part" you may want a number like "110-00001-00". The seqItem table would hold…
0
votes
1 answer

How to start my Serial key from 1 in PostgreSQL

How to start my id column from 1 ? My tabel is : id | origin | destination | duration ----+-------------+-------------+---------- 6 | Paris | New York | 540 7 | Tokyo | Shanghai | 185 8 | Seoul | Mexico City |…
0
votes
1 answer

Share sequence from 2 user in Postgres

In database server Postgres 9.x or Postgres 10.x can I share the same sequence from 2 user? For example in the same database dbTest there are 2 schemas userA is schema owner schemaA with a sequenceA userB is schema owner schemaB Can userB use…
sunrelax
  • 65
  • 9
0
votes
0 answers

HibernateException: Missing sequence or table and SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into

I am fairly new to hibernate and this is very strange - I am trying to run a Spring-Hibernate rest application on tomcat using eclipse. I have an entity defined as below - @Entity @Table(name = "bdp_billing_rec_ref") @NamedQueries(value = {…
Gunwant
  • 949
  • 1
  • 14
  • 29
0
votes
4 answers

Select sequence number not allowed here

I´ve a problem than i can´t resolve a select with a sequence, here´s my query SELECT SEQ_ARRIENDO.nextval, TO_CHAR(SYSDATE,'YYYY') ANNO_PROCESO, cam.nro_patente, ( SELECT COUNT(ac.id_arriendo) FROM …