how to import data with identifier (primary key)
Tue Apr 05 2022 06:32:58 GMT+0000 (Coordinated Universal Time)
Saved by
@Bambibo9799
CREATE TABLE pizza_runner.tes (
id serial4 NOT NULL,
"no" int4 NULL
);
--after that import data as usual
--only need to import the no value only, serial key will automatically generated
----truncate and alter first to restart the primary key into 1
truncate table pizza_runner.tes
ALTER SEQUENCE <tablename>_<id>_seq RESTART WITH 1
ALTER SEQUENCE pizza_runner.tes_id_seq RESTART WITH 1
content_copyCOPY
Comments