【发布时间】:2021-03-12 18:48:46
【问题描述】:
在 postgresql 中这个等价物是什么?
--
-- Index for the table `Artist`
--
ALTER TABLE `Artist`
ADD PRIMARY KEY (`idArtist`),
ADD UNIQUE KEY `name` (`name`,`firstName`);
ADD KEY `idFilm` (`idFilm`);
【问题讨论】:
在 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);
【讨论】:
CREATE UNIQUE INDEX "name" on "Artist" ("name","firstName");documentation