Setting primary key [May 03]

[dummy title body text appended to avoid empty title body]

:raising_hand_man: wkw replied

are u saying if set the primary key when creating the column but it shows not PK after the creation?

:raising_hand_man: Shard replied

I deleted the Id column and now my table has no PK and nocodb wont let me edit the table

:raising_hand_man: Shard replied

Now I want to make another column into PK but apparently “Set as Primary value” doesn’t do it

:raising_hand_man: wkw replied

u need to create a column with PK ticked

:raising_hand_man: wkw replied

like i said before, primary value is different than primary key

:raising_hand_man: wkw replied

see the screenshot i sent

:raising_hand_man: Shard replied

I get an error when I try to create a new column with PK ticked: multiple primary keys for table "table_name" are not allowed

:raising_hand_man: Shard replied

I dropped the existing PK with postgres query, but creating a new column with PK ticked still doesn’t work. Tells me: column "name" of relation "table_name" contains null values

:raising_hand_man: wkw replied

did u hv records?

:raising_hand_man: Shard replied

What do you mean?

:raising_hand_man: wkw replied

i just tried it n it works fine

:raising_hand_man: wkw replied

does your table contain some records before u create new PK

:raising_hand_man: Shard replied

Yes it is an existing table

:raising_hand_man: wkw replied

then u may feed the default value

:raising_hand_man: wkw replied

try sth like this

image0

:raising_hand_man: wkw replied

tick NN to mark it not null

tick PK to make it Primary key

add default value to make existing records to hv a PK value

:raising_hand_man: wkw replied

then u can change it afterwards

:raising_hand_man: Shard replied

Getting this: ALTER TABLE "table_name" ADD "name" character varying NOT NULL DEFAULT placeholder;;alter TABLE "table_name" add constraint "table_name_pkey" PRIMARY KEY("name"); - cannot use column reference in DEFAULT expression

:raising_hand_man: wkw replied

can u screencap your input like i did