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:
table_name: The name of the analytical table that contains the column.It can be specified as a fully qualified name in the
schema_name.table_nameformat, or as just the table name. If you do not specify the analytical schema name, the current schema is used.column_name: The name of the column whose data type is changed.new_data_type: The new data type of the column.For more information about supported data types, refer to Section F.3.
Postgres Pro AXE performs the following actions:
Verifies input parameters and user privileges.
Ensures that the new column data type does not match the previous one.
Ensures that the analytical table is empty or that the new data type is compatible with the previous one:
int8can be changed toint16,int32, orint64int16can be changed toint32orint64int32can be changed toint64uint8can be changed touint16,uint32, oruint64uint16can be changed touint32oruint64uint32can be changed touint64float32can be changed tofloat64
Updates the
column_typevalue for the column in thepga_columnmetadata table.Updates the
view_sqlvalue for the analytical table.
Example 26.3. Executing the metastore.change_column_type stored procedure
SELECT metastore.change_column_type('testtable', 'third_col', 'uint8');