Auto increment PostgreSQL: Revision history

Jump to navigation Jump to search

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

11 May 2026

28 June 2024

  • curprev 14:2214:22, 28 June 2024 Linuxwiki>Wikiadmin 1,154 bytes +185 Auto increment i PostgreSQL
  • curprev 14:2014:20, 28 June 2024 Linuxwiki>Wikiadmin 969 bytes +969 Skapade sidan med '==Auto increment i PostgreSQL== Det finns en "sequence" i Postgres som är ett speciellt databasobjekt vilket genererar en sekvens av heltal. Ofta använd som primary key i en tabell. Skapa en ny tabell som använder detta sequence med: '''CREATE TABLE tabellnamn(''' ''' id SERIAL''' ''' );''' Detta sätter upp id som en auto_increment int i Postgres. Vad Postgres gör detta fall är: CREATE SEQUENCE table_name_id_seq; CREATE TABLE table_name ( id integ...'