Postgresql ALTER TABLE ADD KEY equivalent



在postgresql中与之等价的是什么?

--
-- 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);

最新更新