如何使用 mysql 将当前系统日期插入数据库列
我在表中有三个 *date 字段,定义为 VARCHAR(45),默认值为“00-00-0000”。创建记录时,每个字段都需要当前系统时间的默认值。
我已将其中一个字段从 VARCHAR(45) 更改为 TIMESTAMP,默认值为 CURRENT_TIMESTAMP,效果很好。我想每个表只能有一个数据类型为 TIMESTAMP 的字段。
如何处理表中的其他 2 个字段?我也想 *CURRENT_TIMESTAMP 它们。
谢谢
I have three *date fields in a table defined as VARCHAR(45) with a default value of '00-00-0000'. Each of the fields needs the default value of the current system time when a record is created.
I have changed one of the fields from VARCHAR(45) to TIMESTAMP with default of CURRENT_TIMESTAMP, which works great. I think I can only have a single field with Datatype TIMESTAMP per table.
How do I handle the other 2 fields in the tables? I would like to *CURRENT_TIMESTAMP them too.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
NOW()< /代码>
功能:
Use the
NOW()
function:您可以在 MySQL 查询中使用“NOW()”来填充时间戳列的当前时间。
You can use "NOW()" in a MySQL query to fill in the current time for a timestamp column.
您可以将 Now() 写入字段
You can write Now() to the fields