我正在使用Netezza序列生成seq_id。密钥是根据列A,B的唯一组合生成的,但我面临的问题是,对于两个不同的唯一组合,我得到相同的序列ID。能帮助我了吗?
SEQ_ID A, B
8000 1,2
8000 3,4
9000 1,8
1000 7,9
使用查询
SELECT
NEXT VALUE FOR SEQ_A_B_ID AS SEQ_ID ,
A.A ,
A.B
FROM(
SELECT DISTINCT A , B FROM TABLE1
where A|| '-' || B NOT IN (SELECT A || '-' || B FROM TABLE12)
) A
;
序列定义
CREATE SEQUENCE DSADM.SEQ_A_B_ID AS BIGINT
START WITH 5476300001
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
NO CYCLE;
谢谢,
抱歉,我添加了测试数据,实际数据如下所示
5488310365 3099505744582340000 5305804635993960000
5488310365 3094070450584350000 6702650425474680000
,SELECT * FROM DSADM.SEQ_A_B_ID
的输出为
SEQUENCE_NAME: SEQ_A_B_ID
LAST_VALUE: 5476300001
INCREMENT_BY: 1
MAX_VALUE: 9223372036854780000
MIN_VALUE:1
CACHE_VALUE: 100000
LOG_CNT:1
IS_CYCLED:FALSE
IS_CALLED:FALSE
DATATYPE:20