We can alter the column without dropping the table by using the following syntax:
Syntax for adding new column name to table
ALTER TABLE <tablename> ADD <new_col> <data_type>;
Syntax to modify a column datatype length
ALTER TABLE <Table_Name>
ADD <Existing_Column_Name> <New_Data_Type(New_Length)>
Here are the results while applying above syntax for changing column's data type:
3558: Cannot alter the specified attribute(s) for f_name.
VARCHAR ( from VARCHAR(20) TO VARCHAR(22)) - successfully executed
INTEGER ( FROM INTEGER TO DECIMAL(15,0)) - gives syntax error - 3558
CHAR ( FROM CHAR (5) TO CHAR (7)) - syntax error - 3558
TIMESTAMP ( FROM TIMESTAMP(0) TO TIMESTAMP(1) )- syntax error - 3558
DECIMAL (FROM DECIMAL(15,0) TO DECIMAL(15,1) )- syntax error - 3558
It proves that these procedure is limited to VARCHAR.
Also, The execution will get successful if only if you decrease the length of the column. Try that
ReplyDelete