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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...