Add column to existing table

by Mukesh Dak on 2010 Jan 10

in SQL

1. Add a column in a table

ALTER TABLE `ess` ADD `day` DATE NOT NULL COMMENT 'date of the day' AFTER `recid` ,
ADD UNIQUE (
`day`
)

2. Or it can me similar to this also

ALTER TABLE `diary` ADD `duedate` DATE default "2010-01-01" COMMENT 'due date of the entry' AFTER `modified`

3. Third example

ALTER TABLE `diary_options` ADD `show_duedate` INT( 1 ) NOT NULL COMMENT 'to show duedate or not' AFTER `show_modified`

Leave a Comment

Previous post:

Next post: