I would like to know if I can use numbers in conjuction of letters in column names. If yes, I would like to know if it is advisable.
Asked
Active
Viewed 867 times
1
-
possible duplicate of [Can a number used to name a sql column](http://stackoverflow.com/questions/7975417/can-a-number-used-to-name-a-sql-column) – Ben Jan 20 '15 at 18:05
-
@Ben I modified my question – tirenweb Jan 20 '15 at 18:11
-
Can you add an example of a "normally numbers"? Maybe add the create statement you're looking to use. – Ray Jan 20 '15 at 18:12
-
@Ray I modified the text of the question. – tirenweb Jan 20 '15 at 18:15
1 Answers
0
Yes you can, it does not violate anything (at least mysql 5.5 and higher).
Refer to this for full spec of naming for schema elements: http://dev.mysql.com/doc/refman/5.6/en/identifiers.html
However, I would not recommending using all numbers entirely like "123", "245" as doing this:
- it's not descriptive or indicative of anything anyone other than you would be able to discern
- need to escape use in queries with backtics.
Using numbers in column names in conjunction with letters is perfectly fine (such as "order_1", "order_2", ect...), no backticks to access needed.

Ray
- 40,256
- 21
- 101
- 138
-
must I use backticks even if the numbers are in the middle of the name? For example `name_1_surname` or like this `name_1` – tirenweb Jan 20 '15 at 18:12
-
1Backticks needs to be used when the name of the object (database, table, column, index, trigger etc) can be interpreted as something else in the context. For example, if it is a MySQL reserved word or a function name then, most of the times, it needs to be enclosed in backticks. Also, if the name contains only of digits then it always needs to be enclosed in backticks or MySQL will interpret it as a number instead. – axiac Jan 20 '15 at 18:18