Monday, November 25, 2013

Add a Date/time Column with a default date to a table in MySQL

This is again a mundane task which any one of us might have been required to do. Please find the simple DDL.

If the requirement is to alter table Users with a pwdchangedate with a default date of today, here goes the DDL

ALTER TABLE Users
    ADD pwdchangedate
    DATETIME
    NOT NULL
    DEFAULT now();


No comments:

Post a Comment