Wednesday 15 September 2010

sql - Time Data Type - MySQL -


let me know date & amp; At the time of recording, (time of production)

I tried to use this statement but every time I get an error message:

  'OrderDate 'Date default (gaterate ()), zero,   

When I tried to edit it visually, PHPMYSQL was showing a message that the field data type was successfully changed, But it was not.

Bottom line; To set the value of the field as the time of setting, I should know the correct data type / function

Thanks

To get an area that automatically sets the date Make records while doing:

  Order date timestamp default CURRENT_TIMESTAMP;   

Before MySQL 5.6, if you are required to start a DATETIME field type, you can set your OrderDate Can define P>

  order date datetime default 0 zero;   

and use TRIGGER to assign a date:

  DROP trigger if present, then ambient_nertte; DELIMITER Turn on trigger - first IFNULL (NEW.OrderDate, 0) & lt; = 0 then setNEW.OrderDate = Now (); end if; End; // DELIMITER;   

With MySQL 5.6, the DATETIME field can start automatically because TIMESTAMP s is now done.

No comments:

Post a Comment