A
A
Albert Kazan2020-04-27 21:39:39
MySQL
Albert Kazan, 2020-04-27 21:39:39

ENUM or INT for this purpose?

Recently at work, I was told to use ENUM better in tables, although I had never used it before.
Now all ENUMs represent values ​​in integers 0, 1, 2, and so on. Most commonly 0 and 1 to indicate state. Type here is probably protection from the fact that there are not randomly assigned numbers out of range.
And for the purposes of future optimization, is it worse than just setting the type to INT and not looking at some unlikely chance that PHP will set the wrong number?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-04-27
@firedragon

Use your company's coding style. This will avoid misunderstandings.
As for other projects. Now there is an ORM and they perfectly map everything to everything. That is, you will think in terms of the PL, not the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question