SQL Server:无法在时间戳列中插入显式值

编程入门 行业动态 更新时间:2024-10-22 19:41:39
本文介绍了SQL Server:无法在时间戳列中插入显式值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用该语句时

create table demo ( ts timestamp ) insert into demo select current_timestamp

我收到以下错误:

无法在时间戳列中插入显式值.使用带有列列表的 INSERT 来排除时间戳列,或者在时间戳列中插入一个 DEFAULT

Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column

如何将当前时间插入到 timestamp 列中?

How do I insert the current time to a timestamp column?

推荐答案

根据 MSDN,timestamp

是一种公开自动生成的唯一二进制的数据类型数据库中的数字.时间戳一般用作一种机制用于版本标记表行.存储大小为 8 字节.这时间戳数据类型只是一个递增的数字,而不是保留日期或时间.要记录日期或时间,请使用日期时间数据类型.

Is a data type that exposes automatically generated, unique binary numbers within a database. timestamp is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The timestamp data type is just an incrementing number and does not preserve a date or a time. To record a date or time, use a datetime data type.

您可能正在寻找 datetime 数据类型.

You're probably looking for the datetime data type instead.

更多推荐

SQL Server:无法在时间戳列中插入显式值

本文发布于:2023-11-16 01:35:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1599806.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   Server   SQL   戳列中   显式值

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!