Now, suppose we want to convert the serial_no column from type INTEGER to BIGINTEGER. Now, let us populate it INSERT INTO marks(serial_no,name, roll_no, marks_obtained,
Let us create a new table marks − CREATE TABLE marks( Let us understand both the cases using an example. However, if you convert a TEXT or a VARCHAR entry to INTEGER, you will not be able to do that by default, unless you provide an expression for converting the existing TEXT/VARCHAR values to an integer. For instance, if you convert a column of type INTEGER to type BIGINTEGER, you need not use any expression for the conversion of existing entries to the new types. It is used when you need to use an expression for converting the existing entries in that column from the current type to the new type. The USING part of the syntax is optional. Please note that altering the type of a column is not recommended generally, especially if your table has a lot of entries already. In order to change the type of a column, the syntax is ALTER TABLE table_nameĪLTER COLUMN column_name TYPE new_data_type USING expression