tencent cloud

TencentDB for PostgreSQL

Structural Compatibility Check

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2025-04-30 17:58:55

Check Detail

If the target database version is 12 or higher, and the table to be migrated contains data types abstime, reltime and tinterval, the verification task will report an error.
<data types abstime, reltime and tinterval are some older date and time types which have been deprecated in new PostgreSQL Versions. It is recommend using following types as alternatives:
abstime: Can be substituted with timestamp or timestamp with time zone types. These types provide a broader range of date and time representation capabilities.
reltime: Can be substituted with interval type. interval type is used to represent time intervals and can include units such as year, month, day, hour, minute, and second.
tinterval: Can be substituted with tsrange or tstzrange types. These types are used to represent time ranges and can include start time and end time.

Remediation Method

The modification methods for the three data types abstime, reltime and tinterval are similar. First, create a new column. Convert the old data format to the new data format and store it in the new column. After verifying that the data in the new column is correct, delete the old column. Finally, rename the new column to the name of the old column as needed.
The following takes modifying abstime to timestamp as an example for introduction.
1. In the table where the verification task prompts an error, add a new timestamp column.
ALTER TABLE your_table ADD COLUMN new_column TIMESTAMP;
2. Convert the data in the abstime column to the timestamp type and store the result in a new column.
UPDATE your_table SET new_column = your_abstime_column::TIMESTAMP;
3. Verify if data in the new column is correct.
SELECT * FROM your_table;
4. If you confirm that the data in the new column is correct, you can delete the old abstime column.
ALTER TABLE your_table DROP COLUMN your_abstime_column;
5. If necessary, you can rename the new column to the name of the old column.
ALTER TABLE your_table RENAME COLUMN new_column TO your_abstime_column;

Ajuda e Suporte

Esta página foi útil?

comentários