如何获取当前日期&在 MySQL 中的时间?

2021-11-20 00:00:00 datetime sql 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())

相关文章