增量表能夠生成標識列,如下所示:
CREATE TABLE TestMe (
pKey bigint GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
id bigint,
commentary string
)
USING DELTA
OPTIONS (PATH "/mnt/Delta/Testing/TestMe")
但是,如果不手動編輯似乎有風險的變更日志檔案,似乎沒有辦法重置計數器。
如果我想截斷表并在其中放置一組新資料,我怎么能做到這一點而不慢慢累積數億/數十億的標識列(插入計數器的每個資料都只會上升并且永遠不會重置)?
uj5u.com熱心網友回復:
請嘗試這種方式
CREATE TABLE TestMe (
pKey bigint GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
id bigint,
commentary string
);
insert into TestMe (id,commentary) values (1,'a'),(2,'b'),(3,'c');
select * from TestMe;
truncate table TestMe;
describe history TestMe;
Restore Table TestMe to version as of 0;
insert into TestMe (id,commentary) values (1,'a'),(2,'b'),(3,'c');
uj5u.com熱心網友回復:
找到了另一種解決方法
CREATE or REPLACE TABLE TestMe (
pKey bigint GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
id bigint,
commentary string
);
insert into TestMe (id,commentary) values (1,'a'),(2,'b'),(3,'c');
select * from TestMe;
-- Rerun Create or Replace resets the identity
CREATE or REPLACE TABLE TestMe (
pKey bigint GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
id bigint,
commentary string
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/483632.html
