I was wondering if date
is actually a valid mysql column name?
According to the manual
MySQL permits some keywords to be used as unquoted identifiers because many people previously used them. Examples are those in the following list:
- ACTION
- BIT
- DATE
- ENUM
- NO
- TEXT
- TIME
- TIMESTAMP
So, from that I gather you are allowed to use date
as a column name, but it doesn't say that it is not recommended.
So, are there any implications to using date
as a column name?
MySQL retrieves and displays DATE values in ' YYYY-MM-DD ' format. The supported range is '1000-01-01' to '9999-12-31' . The DATETIME type is used for values that contain both date and time parts.
Column names must contain only A to Z, 0 to 9, and underscore (_) characters. Column names can contain multiple underscores. The column name must not be very generic. Avoid words such as term, multiplier, description, name, code, and so on.
MySQL supports SQL data types in several categories: numeric types, date and time types, string (character and byte) types, spatial types, and the JSON data type.
SQL Date Data TypesMySQL comes with the following data types for storing a date or a date/time value in the database: DATE - format YYYY-MM-DD. DATETIME - format: YYYY-MM-DD HH:MI:SS. TIMESTAMP - format: YYYY-MM-DD HH:MI:SS.
I was able to add a column named date
to the database, no quotes required.
So, yes, it's possible.
But you don't need to. Choose another column name, e.g. "date_recorded"
. Not only is it better syntactically, but it's more descriptive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With