Reputation:
I know this is a noob question and I can't find any answer on google, but I want the opinions and suggestions of expert here in sql in terms of setting the data type of columns.
Is it okay if I set all my columns to varchar? even the value of the columns are dates and numbers? Is there any difference if I use Date and Varchar?
I will totally appreciate all the answers, Thank you
Upvotes: 0
Views: 555
Reputation: 2004
The best practice is always a good place to start. Another important issue to take in to consideration is "what is this database for"? If it is for storing dates, why not use dates as the data type. As C0dem0nkey described converting data takes time and with big tables can be quite tricky.
Upvotes: 1
Reputation: 686
i think doing so will result to an error prone system. How can you use operators on datetime if you use varchar? One way or the other, you have to convert them to datetime just to compare then convert them back to string to store again which takes much much time.
List of Best Practice MySQL Data Types
Here's a helpful post. Regards!
Upvotes: 0