nocodb/reset_id_pkey.md
... ...
@@ -0,0 +1,37 @@
1
+
2
+
3
+/ # psql -d skydive -U skydive
4
+psql (17.2)
5
+Type "help" for help.
6
+
7
+skydive=> \dt
8
+ List of relations
9
+ Schema | Name | Type | Owner
10
+---------+------------------------+-------+---------
11
+ skydive | Events | table | skydive
12
+ skydive | FTBLP_tunnel_timesheet | table | skydive
13
+ skydive | VFS_draw_FAI_indoor | table | skydive
14
+ skydive | epheo_logbook | table | skydive
15
+(4 rows)
16
+
17
+skydive=> ALTER TABLE epheo_logbook ADD COLUMN new_id SERIAL;
18
+ALTER TABLE
19
+skydive=> ALTER TABLE epheo_logbook ADD COLUMN new_id SERIAL;
20
+ALTER TABLE
21
+
22
+skydive=> SELECT conname
23
+skydive-> FROM pg_constraint
24
+skydive-> WHERE conrelid = 'epheo_logbook'::regclass AND contype = 'p';
25
+ conname
26
+--------------
27
+ logbook_pkey
28
+(1 row)
29
+
30
+skydive=> ALTER TABLE epheo_logbook DROP CONSTRAINT logbook_pkey;
31
+ALTER TABLE
32
+skydive=> ALTER TABLE epheo_logbook DROP COLUMN id;
33
+ALTER TABLE
34
+skydive=> ALTER TABLE epheo_logbook RENAME COLUMN new_id TO id;
35
+ALTER TABLE
36
+skydive=> ALTER TABLE epheo_logbook ADD PRIMARY KEY (id);
37
+ALTER TABLE