Sql postgres是否允许在多列索引中使用空值?

Sql postgres是否允许在多列索引中使用空值?,sql,postgresql,Sql,Postgresql,我想在一个表上创建一个多列索引(a、B、C),其中C是一个可为空的列。当C为null时,该索引是否存储值?oracle db似乎允许这样做,但不确定postgres是否允许这样做是的,空值将存储在索引中,与oracle不同的是,如果所有列值都为空,则也是如此 Oracle和Postgres处理带有空值的唯一的索引的方式有所不同: 以下内容适用于Postgres,但在Oracle中会失败 create table test (a int, b int, c int); create unique

我想在一个表上创建一个多列索引(a、B、C),其中C是一个可为空的列。当C为null时,该索引是否存储值?oracle db似乎允许这样做,但不确定postgres是否允许这样做是的,空值将存储在索引中,与oracle不同的是,如果所有列值都为空,则也是如此

Oracle和Postgres处理带有空值的唯一的索引的方式有所不同:

以下内容适用于Postgres,但在Oracle中会失败

create table test (a int, b int, c int);
create unique index on test(a, b, c);
insert into test values (1,1,null);
insert into test values (1,1,null);

是,空值将存储在索引中,与Oracle不同,如果所有列值都为空,则也是如此

Oracle和Postgres处理带有空值的唯一的索引的方式有所不同:

以下内容适用于Postgres,但在Oracle中会失败

create table test (a int, b int, c int);
create unique index on test(a, b, c);
insert into test values (1,1,null);
insert into test values (1,1,null);

PostgreSQL将
NULL
视为
distinct
值,因此,一列中可以有多个带索引的空值。

PostgreSQL将
NULL
视为
distinct
值,因此,可以在带索引的列中有多个空值。

是-可以。但是主键不接受空值。是-可以。但主键不接受空值。