-3

How do I create a table with one column having year e.g. 2019, 2018 as the only data type?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

3 Answers3

1

You can store a year either as an integer (or smallint, if your database supports it), decimal(4, 0), or as a char(4).

You would use a numeric representation if you planned to do arithmetic on the years -- say adding 3 years or taking the difference. You would use a string representation if the value were only for show.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

Use INT datatype. There is no need to use Decimal or Varchar

0

I would use type DATE because you may want to use functions or expressions that use data with type DATE, perhaps in a different table.

Marichyasana
  • 2,966
  • 1
  • 19
  • 20