SQL Server NULL 和 DEFAULT 列规范

发布于 2024-10-24 00:42:31 字数 409 浏览 1 评论 0原文

仅使用 Allow Nulls = Yes 声明列与同时使用 Default Value or Binding = NULLAllow Nulls = Yes< 声明列有何区别/代码>?

我特别感兴趣的是 JDBC 和 wasNull 方法语义是否存在差异。我的印象是,Allow Nulls = Yes(没有 DEFAULT 规范)足以允许您从 INSERT 子句中排除该列,并期望插入行中该字段的值被分配 SQL NULL 值...

有人向我建议,当我没有将 DEFAULT 显式指定为 NULL 时,wasNull 行为不当,特别是对于我的数据库中的 NVARCHAR 字段,该字段是使用结果集的 getString 方法从结果集中检索的...

Is there a difference between declaring a column with just Allow Nulls = Yes as compared to declaring it with both Default Value or Binding = NULL AND Allow Nulls = Yes?

In particular I'm interested in if there is a difference with respect to JDBC and the wasNull method semantics. My impression was that Allow Nulls = Yes (without a DEFAULT spec) was sufficient to allow you to exclude the column from an INSERT clause and expect that the value of that field in the inserted row is assigned the SQL NULL value...

It has been suggested to me that wasNull misbehaves for specifically for an NVARCHAR field in my database that is retrieved from a result set using the getString method of the result set when I didn't have the DEFAULT specified explicitly as NULL...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼趣 2024-10-31 00:42:31

您可以将列声明为默认值 NULL,但这是一件毫无意义的事情。我期望它实现的只是稍微减慢插入过程(因为它必须查找默认值)。 Allow Nulls = Yes 应该就足够了。

我不明白 wasNull 具体是如何进入这个领域的,因为据我所知,wasNull 在使用结果集时使用,而不是在执行插入操作时使用。

You can declare a column to have a default value of NULL, but it's a spectacularly pointless thing to do. All I'd expect it to achieve is to minutely slow down the insertion process (since it has to look up the default value). Allow Nulls = Yes should be sufficient.

I don't see how wasNull comes into this specifically, since, so far as I understand it, wasNull is used when consuming result sets, not when performing insert operations.

欢你一世 2024-10-31 00:42:31

如果 INSERT 语句的列列表中未提供该值,则仅使列允许空值并不能保证其值为 NULL

联机丛书参数 标题。查看(column_list)

Simply making the column allow nulls does not guarantee that it will have the value NULL if it is not provided in an INSERT statement's column list.

Books Online has the gory details under the Arguments heading. Look at (column_list).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文