Postgres 的 Oracle 主键
Oracle Primary Key to Postgres
我正在将 tables 从 Oracle 迁移到 Postgres。
在 Oracle table 上创建主键时,它会隐式创建一个具有相同名称的唯一索引。
但是在 Postgres 中没有创建这样的索引,或者它在数据字典中不可见 tables.
Postgres 不允许使用主键名称创建索引。我想知道 Postgres 中主键列上是否需要唯一索引。如果我不为主键列创建唯一索引,它会以任何方式改变查询性能吗?提前致谢。
这是不正确的:
create table pk_test (id integer primary key);
\d pk_test
Table "public.pk_test"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
Indexes:
"pk_test_pkey" PRIMARY KEY, btree (id)
我正在将 tables 从 Oracle 迁移到 Postgres。
在 Oracle table 上创建主键时,它会隐式创建一个具有相同名称的唯一索引。 但是在 Postgres 中没有创建这样的索引,或者它在数据字典中不可见 tables.
Postgres 不允许使用主键名称创建索引。我想知道 Postgres 中主键列上是否需要唯一索引。如果我不为主键列创建唯一索引,它会以任何方式改变查询性能吗?提前致谢。
这是不正确的:
create table pk_test (id integer primary key);
\d pk_test
Table "public.pk_test"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
Indexes:
"pk_test_pkey" PRIMARY KEY, btree (id)