Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is best column type for status in MySQL

I have status field that can get some values(not just two) like: pending,active, inactive, inactive by admin, archived.

what mysql field type should I use for performance and readability?

I found two solution. which of these is better and why?(if any other solution let me know):

1- use tinyint and in comment mention that each number is for what

2- use varchar and put status directly into it

like image 333
mohsenJsh Avatar asked Oct 11 '25 21:10

mohsenJsh


1 Answers

My opinion would be that if you are simply selecting the value then it would not matter whether you will use varchar or tinyint.

But if you are going to use it in some where condition then tinyint would have an edge over varchar. Also it is recommended to choose the smallest data type possible.

like image 98
Rahul Tripathi Avatar answered Oct 14 '25 10:10

Rahul Tripathi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!