How to change MySQL date format for database?(如何更改数据库的 MySQL 日期格式?)
问题描述
我们在 FileMaker 中使用 MySQL 数据库.看来 FileMaker 在读取 MySQL 表时,只会接受 m/d/y 格式的日期.
We are using a MySQL database with FileMaker. It appears that when FileMaker is reading the MySQL tables, it will only accept dates in the format of m/d/y.
有什么方法可以让我们的 MySQL 数据库将其默认格式更改为 m/d/y 而不是 YYYY-MM-DD?
Is there any way I can get our MySQL database to change its default format to be m/d/y instead of YYYY-MM-DD?
我知道我可以在单个 SELECT 查询上使用 DATE_FORMAT() 函数,但我想看看我是否可以更改默认格式.
I know I can use the DATE_FORMAT() function on individual SELECT queries but I want to see if I can just change the default formatting.
推荐答案
多读一点发现可以更改特定字段的格式 但不建议这样做.
Reading a little more I found you can change the format for an specific field but there is not recommended.
您无法更改存储格式
你可以设置 ALLOW_INVALID_DATES 并以您希望的格式保存日期,但我真的不建议这样做.
you could set ALLOW_INVALID_DATES and save the dates with the format you wish but I really don't recommend that.
如果您的字段未编入索引,则在进行选择时调用 DATE_FORMAT()
没有问题,唯一的问题是在这种情况下您是否需要为该字段进行选择由于您正在调用该函数,因此不会使用索引.
if your field isn't indexed there is not issue on call DATE_FORMAT()
when you are doing the select, the only issue is if you need to make a select for that field in which case the index wont be used because you are calling the function.
这篇关于如何更改数据库的 MySQL 日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何更改数据库的 MySQL 日期格式?


基础教程推荐
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01