26.3. Changing Column Data Type (metastore.change_column_type) #

Required privileges: Postgres Pro AXE administrator only. For more information about stored procedures and privileges, refer to Section 22.1.

Execute the following command:

  SELECT metastore.change_column_type('table_name', 'column_name', 'new_data_type');

Where:

Postgres Pro AXE performs the following actions:

  1. Verifies input parameters and user privileges.

  2. Ensures that the new column data type does not match the previous one.

  3. Ensures that the analytical table is empty or that the new data type is compatible with the previous one:

    • int8 can be changed to int16, int32, or int64

    • int16 can be changed to int32 or int64

    • int32 can be changed to int64

    • uint8 can be changed to uint16, uint32, or uint64

    • uint16 can be changed to uint32 or uint64

    • uint32 can be changed to uint64

    • float32 can be changed to float64

  4. Updates the column_type value for the column in the pga_column metadata table.

  5. Updates the view_sql value for the analytical table.

Example 26.3. Executing the metastore.change_column_type stored procedure

  SELECT metastore.change_column_type('testtable', 'third_col', 'uint8');