9951 explained code solutions for 126 technologies


mariadbWhat type to use for a year in Mariadb?


The type to use for a year in Mariadb is YEAR(4). This type is used to store a year in 4 digits format, such as 2020.

Example code

CREATE TABLE mytable (
  year_column YEAR(4)
);

Output example

Query OK, 0 rows affected (0.02 sec)

Code explanation

  • CREATE TABLE: This is a SQL command used to create a new table.
  • mytable: This is the name of the table being created.
  • year_column: This is the name of the column being created.
  • YEAR(4): This is the type of the column being created. It is used to store a year in 4 digits format.

Helpful links

Edit this code on GitHub