Postgresql ALTER TABLE ADD KEY 等效

问题描述

postgresql 中的 this 是什么?

--
-- Index for the table `Artist`
--
ALTER TABLE `Artist`
    ADD PRIMARY KEY (`idArtist`),ADD UNIQUE KEY `name` (`name`,`firstName`);
    ADD KEY `idFilm` (`idFilm`);

解决方法

添加主键也是一样。

alter table artist
  add primary key (idartist);

对于唯一约束,您有两种选择:

alter table artist
  add constraint name unique (name,firstname);

或唯一索引:

create unique index name on artist (name,firstname);

我认为 key 的事情,只需添加一个常规索引:

create index idfilm on artist (idfilm);