Mysql Alter Column Default

Mysql Alter Column Default is used to modify the table and add a default
column to Null.
Understand with Example
The Tutorial illustrate an example from 'Mysql Alter Column Default'. To
understand and grasp this example we create a table 'userform' with
required fieldnames and datatypes respectively.The table 'userform' has a
primary key ID column.
Create table "userform":
CREATE TABLE `userform` (
`ID` int(11) NOT NULL auto_increment,
`username` varchar(100) default NULL,
`fname` varchar(100) default NULL,
`email` varchar(100) default NULL,
`count` bigint(20) default NULL,
PRIMARY KEY (`ID`)
) |
+----+----------+---------+----------------------+-------+
| ID | username | fname | email | count |
+----+----------+---------+----------------------+-------+
| 1 | vineet | vineet | vineet@roseindia.net | 0 |
| 2 | sourabh | Sourabh | srbh@roseindia.net | 0 |
+----+----------+---------+----------------------+-------+ |
Alter the table 'userform' and add column to
set default:
The Query Alter is used to modify table 'usertable' and add the column
default value to Null.
| ALTER table usertable Modify last_name varchar(50) null; |
Describe userform:
The Describe table is used to show the table fieldname, Type, Null,
Key, Default etc.
Output
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| username | varchar(50) | NO | | | |
| first_name | varchar(200) | NO | | | |
| last_name | varchar(50) | YES | | | |
+------------+--------------+------+-----+---------+-------+ |

|