Answer the question
In order to leave comments, you need to log in
How to do AUTO_INCREMENT in postgresql?
What can replace the following lines from MySQL to PostgreSQL?
ALTER TABLE `commands`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
Answer the question
In order to leave comments, you need to log in
If you need to create a table, then autoincrement is done like this:
CREATE TABLE commands (
id serial PRIMARY KEY
)
I prefer sequences. About an hour ago, when I found the question, it turned out that my pgAdmin 4 was seriously lagging behind. I installed a new one, already 64-bit, connected to the desktop service, and only through the GUI built the following objects, in no hurry. Everything is amazing and comfortable. Hope it comes in handy :)
CREATE SEQUENCE public.testincrement_sequence
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
CREATE TABLE public.testincrement
(
i integer NOT NULL DEFAULT nextval('testincrement_sequence'::regclass),
a character varying(250) COLLATE pg_catalog."default",
dt timestamp without time zone,
un character varying(128) COLLATE pg_catalog."default"
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question