Answers for "postgres column type uuid"

0

postgres change column type to uuid

--  Ensure the UUID extension is installed.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

--  Dropping and recreating the default column value is required because
--  the default INT value is not compatible with the new column type.
ALTER TABLE table_to_alter ALTER COLUMN table_id DROP DEFAULT, 
ALTER COLUMN table_id SET DATA TYPE UUID USING (uuid_generate_v4()), 
ALTER COLUMN table_id SET DEFAULT uuid_generate_v4();
Posted by: Guest on April-15-2021
0

postgressql uuid

SELECT gen_random_uuid();
Posted by: Guest on September-13-2021

Browse Popular Code Answers by Language