mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Update 20230208.1 ⭐️⭐️ Improve your coding skills with temporal values in MySQL.md
This commit is contained in:
parent
85e3f9783e
commit
ea64d5e66d
@ -31,8 +31,6 @@ First, the range of dates that can be used differ. `DATETIME` can hold dates bet
|
||||
|
||||
Second, while both data types allow you to `auto_initialize` or `auto_update` their respective values (with `DEFAULT CURRENT_TIMESTAMP` and `ON UPDATE CURRENT_TIMESTAMP` respectively), doing so was not available for `DATETIME` values until version 5.6.5. You can use one of the MySQL synonyms for `CURRENT_TIMESTAMP` if you choose, such as `NOW()` or `LOCALTIME()`.
|
||||
|
||||
**[ Download now: [MariaDB and MySQL cheat sheet][1] ]**
|
||||
|
||||
If you use `ON UPDATE CURENT_TIMESTAMP` (or one of its synonyms) for a `DATETIME` value, but do not use the `DEFAULT CURRENT_TIMESTAMP` clause, then the column will default to `NULL`. This happens unless you include `NOT NULL` in the table definition, in which case it defaults to zero.
|
||||
|
||||
Another important thing to keep in mind is that although normally neither a `DATETIME` nor a `TIMESTAMP` column have a default value unless you declare one, there is one exception to this rule. The first `TIMESTAMP` column in your table is implicitly created with both `DEFAULT CURRENT_TIMESTAMP` and `ON UPDATE CURRENT_TIMESTAMP` clauses if neither is specified and if the variable `explicit_defaults_for_timestamp` is disabled.
|
||||
|
Loading…
Reference in New Issue
Block a user