CHANGE DATA TYPE
Function
This command is used to change the data type from INT to BIGINT or decimal precision from lower to higher.
Syntax
ALTER TABLE [db_name.]table_name CHANGE col_name col_name changed_column_type;
Parameter Description
Parameter |
Description |
---|---|
db_name |
Name of the database. If this parameter is left unspecified, the current database is selected. |
table_name |
Name of the table. |
col_name |
Name of columns in a table. Column names contain letters, digits, and underscores (_). |
changed_column_type |
The change in the data type. |
Usage Guidelines
- Change of decimal data type from lower precision to higher precision will only be supported for cases where there is no data loss.
- Invalid scenario - Change of decimal precision from (10,2) to (10,5) is not valid as in this case only scale is increased but total number of digits remain the same.
- Valid scenario - Change of decimal precision from (10,2) to (12,3) is valid as the total number of digits are increased by 2 but scale is increased only by 1 which will not lead to any data loss.
- The allowed range is 38,38 (precision, scale) and is a valid upper case scenario which is not resulting in data loss.
Examples
System Response
By running DESCRIBE command, the changed data type for the modified column is displayed.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot