Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » SQL Anywhere 服务器 - 数据库管理 » 启动并连接到数据库 » 数据库文件类型 » SQL Anywhere 数据库创建 » 列数据类型注意事项

 

NULL 和 NOT NULL 列

如果某行要求某列必须有值,应将该列定义为 NOT NULL。否则,该列可以包含 NULL 值,表示没有值。SQL Anywhere 中的缺省设置是允许 NULL 值,但如果没有充分的理由来允许 NULL 值,则应将相应的列显式声明为 NOT NULL。

SQL Anywhere 示例数据库中有一个部门表,在该表中包含名为 DepartmentID、DepartmentName 和 DepartmentHeadID 的列。其定义如下所示:

数据类型 大小 NULL/NOT NULL 约束
DepartmentID integer NOT NULL 主键
DepartmentName char 40 NOT NULL
DepartmentHeadID integer NULL 外键

如果指定 NOT NULL,则必须为该表中的每一行提供列值。

 另请参见