/ # psql -d skydive -U skydive
psql (17.2)
Type "help" for help.
skydive=> \dt
List of relations
Schema | Name | Type | Owner
---------+------------------------+-------+---------
skydive | Events | table | skydive
skydive | FTBLP_tunnel_timesheet | table | skydive
skydive | VFS_draw_FAI_indoor | table | skydive
skydive | epheo_logbook | table | skydive
(4 rows)
skydive=> ALTER TABLE epheo_logbook ADD COLUMN new_id SERIAL;
ALTER TABLE
skydive=> ALTER TABLE epheo_logbook ADD COLUMN new_id SERIAL;
ALTER TABLE
skydive=> SELECT conname
skydive-> FROM pg_constraint
skydive-> WHERE conrelid = 'epheo_logbook'::regclass AND contype = 'p';
conname
--------------
logbook_pkey
(1 row)
skydive=> ALTER TABLE epheo_logbook DROP CONSTRAINT logbook_pkey;
ALTER TABLE
skydive=> ALTER TABLE epheo_logbook DROP COLUMN id;
ALTER TABLE
skydive=> ALTER TABLE epheo_logbook RENAME COLUMN new_id TO id;
ALTER TABLE
skydive=> ALTER TABLE epheo_logbook ADD PRIMARY KEY (id);
ALTER TABLE