更新时间:2022-11-26 09:56:45
不,我不认为这是可能的.
No, I don't think this is possible.
您可以创建一个 UNIQUE INDEX
,其效果与 PRIMARY KEY 基本相同:
You can create a UNIQUE INDEX
which has essentially the same effect as a PRIMARY KEY:
CREATE UNIQUE INDEX pk_index ON "table1"("field1","field2");
此外,我看不到您架构的逻辑,即 -> 如果一列是自动增量并且您不打算手动弄乱这些值,无论如何它都会是唯一的,所以它很简单短主键.为什么要复合?不过,您可能有充分的理由在列组合上创建另一个索引.
Besides, I fail to see the logic of your schema, that is -> if a column is autoincrement and you don't intend to mess with the values manually, it's going to be unique anyway, so it makes a good simple short primary key. Why the composite? You may have good reasons to make another index on the combination of columns, though.