Auto Increment field

I would like to be able to specify an id field as auto increment

3 Likes

+1, it’s the only missing essential feature for me to implement my SQL exports

Thanks for your request! Yes this is something we’re working on actually. I’d imagine when it is ready, the syntax would be like:

Table users {
  id integer [pk, increment]
  name varchar [not null]
}
4 Likes

Hi, it would also be great to have this using the Oracle/Postgres10+ syntax:

Table table_name {
    id int [pk, increment]
}

would yield (when exporting Postgres)

CREATE TABLE table_name (
    id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
);
1 Like

Hi @Nspector @Striffly @MarcusCemes, I’m Jia Wen from the dbdiagram.io team.
We are happy to announce, we have launched our auto-increment syntax!

Table users {
  id integer [pk, increment]
  name varchar [not null]
}

For more details, do check out our Release Note: Support auto-increment | dbdiagram Docs

2 Likes

Could you please check if it is possible to modify exporting to Postgres as proposed by @MarcusCemes ?
Currently agent_id integer [pk, increment] is exported as "agent_id" SERIAL PRIMARY KEY.
We would like to see it as

agent_id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY

which is a more modern approach in Postgres.
Thanks in advance!

1 Like