What does null mean in this script? Does it mean that the column can have null values or does it mean that the column's default value is nul?
CREATE TABLE product ( product_nbr int NOT NULL,
product_name varchar(40) NOT NULL,
produ开发者_高级运维ct_status_code char(10) NOT NULL,
start_date date NULL,
end_date date NULL,
raw_material_cost decimal(12,2) NULL,
primary key (product_nbr)
)
It means the column accepts null values. This is the direct opposite of the NOT NULL
declaration you see for your other columns, and is in fact the default declaration.
For a column to have a default value of NULL
, the declaration is DEFAULT NULL
. That in turn implies, of course, that the column accepts null values.
It basically means both since the a column allows NULL and there is no default value set for the column. If you insert into the table and don't specify a value and there is no default value for the column, the value will be null (undefined). If the column is set to NOT NULL and there is no default value, you will receive an error because the column is not allowed to be NULL.
精彩评论