Home  >  Article  >  Database  >  How does MySQL store year values ​​in a table using YEAR data type?

How does MySQL store year values ​​in a table using YEAR data type?

PHPz
PHPzforward
2023-08-28 17:21:02595browse

MySQL 如何使用 YEAR 数据类型在表中存储年份值?

MySQL allows declaring column YEAR type with the help of which we can store year value in the column.

mysql> Create table year1 (Year_Copyright YEAR);
Query OK, 0 rows affected (0.21 sec)

mysql> Insert into year1(Year_Copyright) values (2017);
Query OK, 1 row affected (0.08 sec)

mysql> Select * from year1;
+----------------+
| Year_Copyright |
+----------------+
|          2017  |
+----------------+
1 row in set (0.00 sec)

The above is the detailed content of How does MySQL store year values ​​in a table using YEAR data type?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete