I want to alter a field to nullable and add the default value null.table name 'other_details' column name used_asset which is varchar(100)
ALTER TABLE `other_details` ALTER COLUMN `used_asset` varchar(100) DEFAULT NULL
above query shows error 'syntax error near varchar(100) DEFAULT NULL'
This came from phpmyadmin as preview SQL and it seems to work:
ALTER TABLE `other_details` CHANGE `used_asset` `used_asset` VARCHAR(100) NULL DEFAULT NULL;
Try this
1) Using MODIFY
ALTER TABLE `other_details` MODIFY `used_asset` varchar(100) null;
2) Using CHANGE
Syntax
ALTER TABLE table_name CHANGE column_name column_name type DEFAULT NULL
Example
ALTER TABLE `other_details` CHANGE `used_asset` `used_asset` varchar(100) DEFAULT NULL;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With