DB2数据库序列的移植方法
DB2数据库序列的移植方法
1. 生成以下语句,得到源数据库序列的当前值:
www.zzzyk.com
Sql代码
SELECT
'SELECT ''CREATE SEQUENCE ' || seqname || ' START WITH '' || ' || seqname ||
'.nextval from sysibm.sysdummy1'
FROM
syscat.sequences
WHERE
seqtype='S'
AND seqschema=CURRENT schema
www.zzzyk.com
2. 根据第一步生成的语句,逐句执行产生建立目的数据库序列的SQL语句,如:
Sql代码
SELECT 'CREATE SEQUENCE SEQ_CCP_CM_CLIENT_INFO START WITH ' || SEQ_CCP_CM_CLIENT_INFO.nextval from sysibm.sysdummy1
SELECT 'CREATE SEQUENCE SEQ_CCP_MM_BRODCAST_INFO START WITH ' || SEQ_CCP_MM_BRODCAST_INFO.nextval from sysibm.sysdummy1
SELECT 'CREATE SEQUENCE SEQ_CCP_MM_INDUSTRY_INFO START WITH ' || SEQ_CCP_MM_INDUSTRY_INFO.nextval from sysibm.sysdummy1
SELECT 'CREATE SEQUENCE SEQ_CCP_MM_WARN_LEVEL START WITH ' || SEQ_CCP_MM_WARN_LEVEL.nextval from sysibm.sysdummy1
SELECT 'CREATE SEQUENCE SEQ_CCP_RM_BACK_PLAN START WITH ' || SEQ_CCP_RM_BACK_PLAN.nextval from sysibm.sysdummy1
SELECT 'CREATE SEQUENCE SEQ_CCP_RM_CERT_INFO START WITH ' || SEQ_CCP_RM_CERT_INFO.nextval from sysibm.sysdummy1
SELECT 'CREATE SEQUENCE SEQ_CCP_RM_CLNT_RELATION START WITH ' || SEQ_CCP_RM_CLNT_RELATION.nextval from sysibm.sysdummy1
3. 执行第二步生成的语句。应该还可行列自动化一点,目前没时间测试!