如何在 MySQL 中插入当前日期/时间?

如何在 mysql 中插入当前日期/时间?

T%ignore_a_1% insert current date/ time in MySQL, use the now() function. Let us now see an example.

At first, we will create a table. The CREATE command is used to create a table.

mysql > create table CurrentDateTime-> (-> CurrentTime datetime-> );Query OK, 0 rows affected (1.14 sec)

Syntax to insert the current date/time with the help of insert command and now()

mysql> insert into CurrentDateTime values(now());Query OK, 1 row affected (0.11 sec)

To check that the current date/ time is inserted in the table or not, use the select command.

mysql> select *from CurrentDateTime;

以下是显示我们成功插入当前日期/时间的输出。

+---------------------+| CurrentTime         |+---------------------+| 2018-10-18 13:14:30 |+---------------------+1 row in set (0.00 sec)

以上就是如何在 MySQL 中插入当前日期/时间?的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/113419.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年11月24日 03:31:46
下一篇 2025年11月24日 04:00:25

相关推荐

发表回复

登录后才能评论
关注微信