Answer the question
In order to leave comments, you need to log in
Is it possible to change column type to serial?
There is a table with filled data:
CREATE TABLE "Виплата"
(
old integer NOT NULL,
"Код_договору" integer,
"Дата" timestamp(0) without time zone,
"Сума_виплат" text,
"Оплата" boolean,
"Код" integer,
CONSTRAINT "Виплата_pkey" PRIMARY KEY (old)
)
WITH (
OIDS=FALSE
);
ALTER TABLE "Виплата"
OWNER TO postgres;
ALTER: ALTER TABLE "Виплата" ALTER COLUMN "Код" type serial;
I can't do it, because serial is not a type. ERROR: type "serial" does not exist !
But it is very necessary to do this. Answer the question
In order to leave comments, you need to log in
SERIAL in PostreSQL is not a data type , but an alias for creating a SEQUENCE and DEFAULT VALUE for a column from it. Accordingly, you can manually do the described actions:
CREATE SEQUENCE tablename_colname_seq;
alter TABLE "Виплата" alter column "Код" type integer NOT NULL DEFAULT nextval('tablename_colname_seq');
ALTER SEQUENCE tablename_colname_seq OWNED BY "Виплата"."Код";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question