0

In postgre sql - How do I alter a column which has time stamp. Currently the column is defined as below -
creation_time timestamp(6) with time zone
and i want to make the above column not null also. So i have tried below but had no luck

ALTER TABLE my_table ALTER COLUMN creation_time TYPE timestamp(6) with time zone NOT NULL;

What is the correct syntax ?

2
  • 1
    "Had no luck".. what does that mean? Wrong syntax? or something else? Basically you can't alter a column to be not nullable, if it contains nulls, so my recomendation is - loss the null values and then try again. Also, after quick google search, this it the syntax: ALTER TABLE table_name ALTER COLUMN column_name SET NOT NULL; Commented Oct 20, 2021 at 11:46
  • right.. wrong syntax. thanks sharing right syntax. Commented Oct 20, 2021 at 11:54

1 Answer 1

1

According to the documentation:

alter table my_table alter creation_time set not null;
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.