MySQL
Order of columns in a create statement | Order of columns in a create statement |
|
Can the order of the columns in a create statement make a difference? YES
create table t (
The first timestamp will always be the "automatically generated" time. So if the record is updated, or inserted, this time gets changed. If the order is changed, "timeEnter" is before "timeUpdate", then, "timeEnter" would get updated. First timestamp column updates automatically. Note, in the table above timeEnter will only get updated if passed a null value.
insert into t (a,b,timeEnter) values (1,2,NULL); Hints: Need mm-dd-yyyy hh:mm:ss format? select a,b,DATE_FORMAT(timeUpdate,'%m-%d-%Y %T'),DATE_FORMAT(timeEnter,'%m-%d-%Y %T') from t;
|
