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 日期格式?
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- SQL 临时表问题 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
