如何获取当前日期&在 MySQL 中的时间? [英] How to get current date & time in MySQL?

查看:37
本文介绍了如何获取当前日期&在 MySQL 中的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有像 DATETIME 这样的值或命令,我可以在手动查询中使用它来插入当前日期和时间?

Is there a value or command like DATETIME that I can use in a manual query to insert the current date and time?

INSERT INTO servers (
  server_name, online_status, exchange, disk_space, network_shares
) VALUES(
  'm1', 'ONLINE', 'ONLINE', '100GB', 'ONLINE' 'DATETIME' 
)

最后引用的 DATETIME 值是我想添加当前日期和时间的地方.

The quoted DATETIME value at the end is where I want to add the current date and time.

推荐答案

你可以使用NOW():

INSERT INTO servers (server_name, online_status, exchange, disk_space, network_shares, c_time)
VALUES('m1', 'ONLINE', 'exchange', 'disk_space', 'network_shares', NOW())

这篇关于如何获取当前日期&在 MySQL 中的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆