Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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();
Comment

postgresql change column type string to uuid

ALTER TABLE packages ALTER COLUMN package_id TYPE uuid USING package_id::uuid;
Comment

PREVIOUS NEXT
Code Example
Sql :: docker run postgres locally 
Sql :: mysql backup query 
Sql :: postgres select max value 
Sql :: postgres set default value 
Sql :: sql add column after another column 
Sql :: change postgress password 
Sql :: mysql query to check record exists in database table or not 
Sql :: add column with foreign key constraint sql server 
Sql :: sql string data type 
Sql :: what is integrity constraints 
Sql :: 2nd highest salary in mysql 
Sql :: mysql how to store lat,lng 
Sql :: oracle trigger after logon on database 
Sql :: calculate distance between two latitude longitude points sql 
Sql :: MYSQL select last query 
Sql :: permission denied postgres copy csv command line 
Sql :: sql in array query 
Sql :: sql decimal vs float 
Sql :: postgres set column based on another column 
Sql :: change auto increment mysql 
Sql :: sql mm/dd/yyyy format 
Sql :: ms sql create user 
Sql :: run postgres docker 
Sql :: mysql query single row 
Sql :: create a sqlite database c# 
Sql :: mysql to get column name in database 
Sql :: referential integrity constraint 
Sql :: oracle get running queries 
Sql :: mysql get latest duplicate rows 
Sql :: sql insert from excel 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =