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
More of Mariadb
- How to check version of Mariadb?
- How to list users in Mariadb?
- How to use UUID in Mariadb?
- Mariadb partitioning example
- How to work with XML in Mariadb?
- How to use variables in Mariadb?
- Mariadb procedure example
- How to get current year in Mariadb?
- How to change wait_timeout in Mariadb?
See more codes...