How to get current date & time in MySQL?

后端 未结 10 1204
情深已故
情深已故 2020-11-29 17:18

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_         


        
10条回答
  •  佛祖请我去吃肉
    2020-11-29 17:37

    Use CURRENT_TIMESTAMP() or now()

    Like

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

    or

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

    Replace date_time with the column name you want to use to insert the time.

提交回复
热议问题