简体   繁体   English

SQL Server IS_NULLABLE

[英]SQL Server IS_NULLABLE

Good Morning, 早上好,

Just a quick question what this field actually means? 只是一个简单的问题,这个领域实际上意味着什么?

I am trying to create an export script which follows this standard: 我正在尝试创建遵循此标准的导出脚本:

 lname   varchar(30)     **NOT NULL**,

So if last name is_nullable=yes then would I put NULL rather than NOT NULL at the *'d code. 因此,如果姓氏is_nullable = yes,那么我将在*代码中放置NULL而不是NOT NULL。

Many Thanks, Joel 非常感谢,乔尔

lname   varchar(30)     NOT NULL

Means the field lname does not allow NULL values. 表示字段lname不允许使用NULL值。

lname   varchar(30)     NULL

On the other hand means that NULL values are allowed. 另一方面意味着允许NULL值。

The docs for CREATE TABLE state 用于CREATE TABLE状态的文档

<column_definition> ::=
column_name <data_type>
    [ FILESTREAM ]
    [ COLLATE collation_name ] 
    [ SPARSE ] 
    [ NULL | NOT NULL ]
    [ 
        [ CONSTRAINT constraint_name ] DEFAULT constant_expression ] 
      | [ IDENTITY [ ( seed ,increment ) ] [ NOT FOR REPLICATION ] 
    ]
    [ ROWGUIDCOL ] [ <column_constraint> [ ...n ] ] 

with further explanation 进一步解释

NULL | NOT NULL

Determine whether null values are allowed in the column. 确定是否在该列中允许使用空值。 NULL is not strictly a constraint but can be specified just like NOT NULL. 严格来说,NULL不是严格的约束,但可以像NOT NULL一样指定。 NOT NULL can be specified for computed columns only if PERSISTED is also specified. 仅当还指定了PERSISTED时,才能为计算列指定NOT NULL。

The [ ] brackets mean you don't have to specify either, but given the complexity of the rules around what the default is (see "Nullability Rules Within a Table Definition" in the above link), you're probably better off always saying which you want. [ ]括号中的意思是你没有指定任何,但考虑到周围的默认(参见“空性规则在表定义”,在上面的链接)什么规则的复杂性,你可能会更好过总是说你要哪个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM