I am having trouble converting a table column TYPE from time without time zone to integer.
Is that possible?
Where integer will be equal to seconds.
I am using ALTER table exampleTable ALTER COLUMN time TYPE integer.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This should do it:
ALTER COLUMN is usually only used when you want to preserve the data in that column. In your case the above should work, but doesn’t buy you anything. Dropping the column and then adding a new one with the type
integerand a default value of 0 would be just as efficient.(Btw: you should not use a reserved word like
timeas a column name)Edit
If you do want to convert the existing data then you can use this: