各位大佬:mysql innodb引擎:同等条件下(已加索引), 时间戳(1543388624) 和时分秒(2018-11-28 15:03:44):哪种格式查询快
解决方案 »
- 如何把某个字段的指定记录清空?
- 时间排序问题?不知道难不难
- 如何使postgreSQL能够链接SQL server 2000数据库?
- 如何输出存储过程中的SQL语句,为了查看这个语句是否正确
- mysql如何比较带回车的数据
- 向数据库中插入数据遇到的问题,请指教一下,谢谢.
- mysql的安装要在机器里留下什么吗?为什么重装了几次都不行。
- 我这样用lock table有什么问题呢?正确的应该怎么用啊?
- 要命的问题, 第一步连接服务器都连接不了, help!
- mysql安装完成后,默认的设备名,管理员用户名、口令和数据库是什么,
- where后使用case when的问题
- Exception in thread "main" java.sql.SQLException: Access denied for user 'root'@
11.3.1 The DATE, DATETIME, and TIMESTAMP Types
The DATE, DATETIME, and TIMESTAMP types are related. This section describes their characteristics, how they are similar, and how they differ. MySQL recognizes DATE, DATETIME, and TIMESTAMP values in several formats, described in Section 9.1.3, “Date and Time Literals”. For the DATE and DATETIME range descriptions, “supported” means that although earlier values might work, there is no guarantee.The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision. In particular, any fractional part in a value inserted into a DATETIME or TIMESTAMP column is stored rather than discarded. With the fractional part included, the format for these values is 'YYYY-MM-DD HH:MM:SS[.fraction]', the range for DATETIME values is '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999', and the range for TIMESTAMP values is '1970-01-01 00:00:01.000000' to '2038-01-19 03:14:07.999999'. The fractional part should always be separated from the rest of the time by a decimal point; no other fractional seconds delimiter is recognized. For information about fractional seconds support in MySQL, see Section 11.3.6, “Fractional Seconds in Time Values”.
一般来说, 占用空间越小, 单位内存的可容纳的记录越多,其效率越高。
所以是 timestamp 占优势。但是, timestamp 的范围有限, 难道还过 20 年你开发的东西就不要了?