21

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?

Hailwood
  • 89,623
  • 107
  • 270
  • 423
  • yes, it's valid, but not particularly recommended, because it can/will cause confusion – Marc B Oct 08 '12 at 05:15
  • But what if we have a table `games_played` I would put the columns as `id`. `home_team`, `away_team` `date`. In that instance the `date` column name makes sense, are there implications to using it here? – Hailwood Oct 08 '12 at 05:18
  • 6
    why not `dateplayed`? You may want to have multiple dates record, e.g. `datescheduled`, `dateupdated`, etc... `date` by itself would be rather ambiguous. – Marc B Oct 08 '12 at 05:20
  • The only problem I encountered (running a database with columns named date myself) is the nuisance of always having to quote the column name when typing out a quick query, otherwise, mysql will complain about a syntax error. Apart from that, it's all fine. – Simon Oct 08 '12 at 07:34

1 Answers1

19

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.

dmzza
  • 2,308
  • 1
  • 21
  • 33
Alain Collins
  • 16,268
  • 2
  • 32
  • 55
  • 11
    I think calling it dumb is overly judgemental. If your table is named `game` and the column is named `date`, how is `game_date` more descriptive? `game.game_date` is just redundant. – Vala Apr 26 '16 at 14:12
  • 9
    game_date was a bad example, but being more descriptive is still a Good Thing. How about "date_played", "date_recorded", or something that actually tells you what the column is for. – Alain Collins Apr 27 '16 at 02:55
  • Did you have problems querying the `date` column? – Pathros Jul 28 '22 at 21:29