Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is `date` a valid mysql column name?

Tags:

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?

like image 432
Hailwood Avatar asked Oct 08 '12 05:10

Hailwood


People also ask

Is date supported in MySQL?

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.

What are valid column names in SQL?

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.

Is date a valid data type in SQL?

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.

Is date a data type in MySQL?

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.


1 Answers

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.

like image 131
Alain Collins Avatar answered Sep 19 '22 08:09

Alain Collins