1

I have a column which is stored as TEXT, I would like to change it to UUID in postgres. But I need to run some function on the column first to change it to UUID. Is it possible to do smth like that?

ALTER TABLE am.product ALTER COLUMN p_merchant_id TYPE UUID USING myFunc;

Where myFunc returns UUID with the input merchant_id?

1 Answer 1

2

Yes, that's possible.

You just need to pass the old value to your function:

ALTER TABLE am.product 
   ALTER COLUMN p_merchant_id TYPE UUID USING myfunc(p_merchant_id);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.