Mysql: Setup the format of DATETIME to #39;DD-MM-YYYY HH:MM:SS#39; when creating a table(Mysql:建表时将DATETIME的格式设置为DD-MM-YYYY HH:MM:SS)
问题描述
在谷歌搜索后,我找不到一种方法来创建一个带有 DATETIME
列的新表,默认格式设置为 'DD-MM-YYYY HH:MM:SS代码>'
After googling around, I cannot find a way to create a new table with a DATETIME
column with the default format set to 'DD-MM-YYYY HH:MM:SS
'
我看到一个教程,它是在 phpmyadmin
中完成的,所以我怀疑我可以通过命令行使用 mysql 并在使用
I saw a tutorial in which it was done in phpmyadmin
so I suspect that I could use mysql via command line and achieve the same thing when creating my new table with
CREATE TABLE ()
提前致谢
推荐答案
MySQL 以 'YYYY-MM-DD HH:MM:SS' 格式检索并显示 DATETIME 值."这是来自 mysql 站点.您只能存储这种类型,但您可以在需要显示时使用众多时间格式函数之一来更改它.
"MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format." This is from mysql site. You can store only this type, but you can use one of the many time format functions to change it, when you need to display it.
Mysql 时间和日期函数
例如,这些函数之一是 DATE_FORMAT,可以这样使用:
For example, one of those functions is the DATE_FORMAT, which can be used like so:
SELECT DATE_FORMAT(column_name, '%m/%d/%Y %H:%i') FROM tablename
这篇关于Mysql:建表时将DATETIME的格式设置为'DD-MM-YYYY HH:MM:SS'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Mysql:建表时将DATETIME的格式设置为'DD-MM-YYYY HH:MM:SS'


基础教程推荐
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01