Changing data type of column

Assume that you are using the following command to convert a column to a different data type.

ALTER TABLE products ALTER COLUMN price TYPE numeric(10,2);

Which of these choices is/are TRUE in the given scenario?

  1. This will succeed only if each existing entry in the column can be converted to the new type by an implicit cast.
  2. PostgreSQL will attempt to convert the column’s default value (if any) to the new type, as well as any constraints that involve the column.
  3. Both Choice 1 and 2
  4. None of these

Related Posts