是否可以更改包含现有数据且具有标识列的Teradata表的唯一主索引/主索引?在保留标识列中当前使用的值的同时,最好的方法是什么?
这是当前表DDL:
CREATE MULTISET TABLE AUDIT.AUDIT_DATA_QUALITY_INDICATOR, NO FALLBACK,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO(
DATA_QUALITY_INDICATOR_KEY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY(
START WITH 1
INCREMENT BY 1
MINVALUE -2147483647
MAXVALUE 2147483647
NO CYCLE)
,DATA_QUALITY_INDICATOR VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,DATA_QUALITY_INDICATOR_DESCRIPTION VARCHAR(1000) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,DATA_QUALITY_INDICATOR_TYPE_KEY INTEGER
,DATA_QUALITY_INDICATOR_DEFAULT_BATCH_OWNER VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,DATA_QUALITY_INDICATOR_EXECUTION_ORDER INTEGER NOT NULL
,FLAG_DATA_QUALITY_INDICATOR_ACTIVE VARCHAR(12) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL DEFAULT 'INACTIVE'
,SCRIPT_NAME VARCHAR(500) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,FUNCTION_NAME VARCHAR(500) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,ALERT_THRESHOLD VARCHAR(50) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,ALERT_DISTRIBUTION_LIST VARCHAR(1000) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,SUBJECT_AREA_KEY SMALLINT NOT NULL
,CREATION_DATE TIMESTAMP(6) NOT NULL
,LAST_UPDATE TIMESTAMP(6) NOT NULL
,AUDIT_PROCESS_KEY INTEGER NOT NULL DEFAULT 1
,SPACE_ID VARCHAR(50) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL DEFAULT 'ND'
,FOREIGN KEY ( DATA_QUALITY_INDICATOR_TYPE_KEY ) REFERENCES WITH NO CHECK OPTION AUDIT.AUDIT_DATA_QUALITY_INDICATOR_TYPE ( DATA_QUALITY_INDICATOR_TYPE_KEY )
,FOREIGN KEY ( AUDIT_PROCESS_KEY ) REFERENCES WITH NO CHECK OPTION AUDIT.AUDIT_PROCESS ( AUDIT_PROCESS_KEY )
,FOREIGN KEY ( SUBJECT_AREA_KEY ) REFERENCES WITH NO CHECK OPTION EDW.DIM_SUBJECT_AREA ( SUBJECT_AREA_KEY )
)
UNIQUE PRIMARY INDEX UPI_AUDIT_DATA_QUALITY_INDICATOR ( DATA_QUALITY_INDICATOR_KEY );
我想将其更改为:
CREATE MULTISET TABLE AUDIT.AUDIT_DATA_QUALITY_INDICATOR, NO FALLBACK,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO(
DATA_QUALITY_INDICATOR_KEY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY(
START WITH 1
INCREMENT BY 1
MINVALUE -2147483647
MAXVALUE 2147483647
NO CYCLE)
,DATA_QUALITY_INDICATOR VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,DATA_QUALITY_INDICATOR_DESCRIPTION VARCHAR(1000) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,DATA_QUALITY_INDICATOR_TYPE_KEY INTEGER
,DATA_QUALITY_INDICATOR_DEFAULT_BATCH_OWNER VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,DATA_QUALITY_INDICATOR_EXECUTION_ORDER INTEGER NOT NULL
,FLAG_DATA_QUALITY_INDICATOR_ACTIVE VARCHAR(12) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL DEFAULT 'INACTIVE'
,SCRIPT_NAME VARCHAR(500) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,FUNCTION_NAME VARCHAR(500) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,ALERT_THRESHOLD VARCHAR(50) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,ALERT_DISTRIBUTION_LIST VARCHAR(1000) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
,SUBJECT_AREA_KEY SMALLINT NOT NULL
,CREATION_DATE TIMESTAMP(6) NOT NULL
,LAST_UPDATE TIMESTAMP(6) NOT NULL
,AUDIT_PROCESS_KEY INTEGER NOT NULL DEFAULT 1
,SPACE_ID VARCHAR(50) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL DEFAULT 'ND'
,FOREIGN KEY ( DATA_QUALITY_INDICATOR_TYPE_KEY ) REFERENCES WITH NO CHECK OPTION AUDIT.AUDIT_DATA_QUALITY_INDICATOR_TYPE ( DATA_QUALITY_INDICATOR_TYPE_KEY )
,FOREIGN KEY ( AUDIT_PROCESS_KEY ) REFERENCES WITH NO CHECK OPTION AUDIT.AUDIT_PROCESS ( AUDIT_PROCESS_KEY )
,FOREIGN KEY ( SUBJECT_AREA_KEY ) REFERENCES WITH NO CHECK OPTION EDW.DIM_SUBJECT_AREA ( SUBJECT_AREA_KEY )
)
UNIQUE PRIMARY INDEX UPI_AUDIT_DATA_QUALITY_INDICATOR ( DATA_QUALITY_INDICATOR, SPACE_ID );