Is it possible to change the column type to serial?

Have a table filled with data:

CREATE TABLE "Wiplala"
(
 old integer NOT NULL,
 "Koldogovoru" integer,
 "Date" timestamp(0) without time zone,
 "Sumavel" text,
 "Payment" boolean,
 "Code" integer,
 CONSTRAINT "Vyplatit" PRIMARY KEY (old)
)
WITH (
OIDS=FALSE
);
ALTER TABLE "Wiplala"
 OWNER TO postgres;


Definitely need to change the type of column "Code" in the serial! Normal
ALTER: ALTER TABLE "Wiplala" ALTER COLUMN ID type serial;
can't, because serial is not a type ERROR: type "serial" does not exist ! But make it very necessary.

How to implement it ?
July 9th 19 at 12:49
2 answers
July 9th 19 at 12:51
Solution
SERIAL in PostreSQL is not the data type, and alias to create SEQUENCE and a DEFAULT VALUE for a column out of it. Accordingly, you may handles to do the steps:
CREATE SEQUENCE tablename_colname_seq;
alter TABLE "Wiplala" alter column "Code" type integer NOT NULL DEFAULT nextval('tablename_colname_seq');
Tablename_colname_seq ALTER SEQUENCE OWNED BY "Wiplala"."Code";
July 9th 19 at 12:53
I can only think of the following sequence of actions: adding a new field with the type of serial changes in values of the Code, removal of Code, renaming a field in saerial Code.
Why the field names in Russian? Hurts my eyes :)
In Ukrainian :) a job - tristian_Maggio commented on July 9th 19 at 12:56

Find more questions by tags PostgreSQLSQL