select uuid_generate_v4() as one, uuid_generate_v4() as two;
「one」uuid和「two」uuid是相等的!postgreSQL uuid代
CREATE TABLE "TB"
(
"Id" uuid NOT NULL DEFAULT uuid_generate_v4(),
"Title" character varying NOT NULL,
CONSTRAINT "TB_Class_ID" PRIMARY KEY ("Id")
);
的PostgreSQL 9.0的pgAdmin 1.12.3
insert into "TB" ("Id", "Title") values (uuid_generate_v4(), '111');
insert into "TB" ("Id", "Title") values (uuid_generate_v4(), '111');
insert into "TB" ("Id", "Title") values (uuid_generate_v4(), '111');
或
insert into "TB" ("Title") values ('111');
insert into "TB" ("Title") values ('111');
insert into "TB" ("Title") values ('111');
結果:
ERROR: duplicate key value violates unique constraint "TB_Class_ID"
DETAIL: Key ("Id")=(12ab6634-995a-4688-9a9a-ee8c3fe24395) already exists.
而
postgreSQL maestro 9.2.0.4
insert into "TB" ("Id", "Title") values (uuid_generate_v4(), '111');
insert into "TB" ("Id", "Title") values (uuid_generate_v4(), '111');
insert into "TB" ("Id", "Title") values (uuid_generate_v4(), '111');
結果:1行受影響;
據我所知,藝術大師逐個添加記錄,但爲什麼uuid_generate_v4()在兩次調用後返回相同的值? (在pgAdmin的情況下)。
如何通過一個請求添加多行?
這看起來像是一個bug。嘗試'SELECT random()AS one,random()AS two;'。我得到兩個不同的值,不管我是否在交易中。 'uuid_generate_v4'是'VOLATILE'函數,所以我認爲錯誤在於uuid-ossp模塊或底層庫。 –
是「SELECT random()AS one,random()AS two」獲取不同的值,我不明白爲什麼uuid_generate_v4得到相同的值 –