How to create a primary key using the hash method in postgresql
有没有办法使用哈希方法创建主键? 以下两个陈述都不起作用:
1 2 3 | oid CHAR(30) PRIMARY KEY USING hash PRIMARY KEY(oid) USING hash |
我假设你打算使用哈希索引方法/类型。
主键是约束。一些约束可以创建索引以便正常工作(但不应该依赖这个事实)。 F.ex.
如果需要,您也可以设置哈希索引(除了
1 | CREATE INDEX name ON TABLE USING hash (COLUMN); |
但是,如果你愿意这样做,你应该知道哈希索引有一些限制(直到PostgreSQL 10):
Hash index operations are not presently WAL-logged, so hash indexes might need to be rebuilt with REINDEX after a database crash if there were unwritten changes. Also, changes to hash indexes are not replicated over streaming or file-based replication after the initial base backup, so they give wrong answers to queries that subsequently use them. For these reasons, hash index use is presently discouraged.
也:
Currently, only the B-tree, GiST and GIN index methods support multicolumn indexes.
注意:遗憾的是,
注2: