Reputation:
I want to keep column default value as current date in mysql.what should be its type.i tryied date and timestamp but not allowed.can anybody say me what should be appropriate data type?
Morely i want to keep default value as current date.how it can be done.At begining default value was set
Upvotes: 0
Views: 75
Reputation: 3339
Try:
ALTER TABLE tablename MODIFY columnname TIMESTAMP;
Updated
Simply:
ALTER TABLE tablename CHANGE columnnane TIMESTAMP NOT NULL DEFAULT 'CURRENT_TIMESTAMP'
Upvotes: 1
Reputation: 516
ALTER TABLE tablename
CHANGE fieldname
fieldname
datatype( 11) NOT NULL
Upvotes: 0
Reputation: 436
Try this :
ALTER TABLE MyTable ADD COLUMN realdate DATE;
UPDATE MyTable SET realdate = STR_TO_DATE(textdate, '%d/%m/%y');
Upvotes: 4