About DB Table Date Items

Asked 2 years ago, Updated 2 years ago, 63 views

I have looked at various systems, and the type of date items that I put in the DB table is VARCHAR2 or DATE, so how do I use them differently?
What are the advantages of being VARCHAR2 and DATE?

database

2022-09-30 16:34

2 Answers

It's not limited to the date, but the general rule is to use it if a model is prepared.If you save it as a string, you'll have to do some complicated calculations and comparisons.It's meaningless and buggy.

String types are used only for negative reasons such as having to do so due to data reasons.The Japanese calendar is mixed, so you have to save it as it is, or there is a special meaning for invalid days like n/0th.

Another reason why string types are used is that there are certain strange people who want to follow "anything string type."If you're a terrible person, you might argue that even numbers should be saved as strings.


2022-09-30 16:34

If the date type is provided, I think it is best to use the date type.Stringed storage also has a significant disadvantage in performance.Indexes are not used for comparison of size relationships.Even if a function is provided to calculate the number of days elapsed, you will still need to perform the type conversion in the previous section.

There are few advantages to storing in a string format.If you force it up, it's highly implantable.If the databases are different, the number of valid digits and the range within which they can be stored will vary considerably.Also, I have never said that the behavior of string type varies depending on the locale setting.If you're restricted to using only the least common denominator functionality for compatibility between different databases, you'll also benefit from string storage.


2022-09-30 16:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.