Teradata:如何将范围分区添加到非空表



>我有这样的表:

CREATE SET TABLE ONLINE_BANKING.TRANSACTIONS ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT,
     DEFAULT MERGEBLOCKRATIO
     (
      transaction_id INTEGER NOT NULL,
      date_of_transaction DATE FORMAT 'YYYYMMDD' NOT NULL,
      amount_of_transaction DECIMAL(38,2) NOT NULL,
      transaction_type_code BYTEINT NOT NULL DEFAULT 25 , 
UNIQUE PRIMARY INDEX ( transaction_id );

我想将分区添加到我的填充数据表中date_of_transaction列。

我尝试了这种方式:

ALTER TABLE TRANSACTIONS
MODIFY PRIMARY INDEX (date_of_transaction) -- tried to write different columns, but failed
ADD RANGE BETWEEN DATE '1998-01-01' AND DATE '2015-12-31' EACH INTERVAL '1' MONTH;

但是,Teradata返回了错误:

删除范围/添加范围子句 没有相应的级别,即RANGE_N函数

这意味着什么,我怎样才能实现目标?

不能将分区添加到未分区的现有表,但只能在分区表中添加或删除范围。

唯一的方法是创建一个新表并像这样插入/选择:

CREATE SET TABLE ONLINE_BANKING.TRANSACTIONS_PPI ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT,
     DEFAULT MERGEBLOCKRATIO
     (
      transaction_id INTEGER NOT NULL,
      date_of_transaction DATE FORMAT 'YYYYMMDD' NOT NULL,
      amount_of_transaction DECIMAL(38,2) NOT NULL,
      transaction_type_code BYTEINT NOT NULL DEFAULT 25 , 
      ...)
PRIMARY INDEX ( transaction_id )
PARTITION BY
   RANGE_N (date_of_transaction BETWEEN DATE '1998-01-01' AND DATE '2015-12-31' 
   EACH INTERVAL '1' MONTH);
INSERT INTO ONLINE_BANKING.TRANSACTIONS_PPI
SELECT * FROM ONLINE_BANKING.TRANSACTIONS;
-- when everything is ok
DROP TABLE ONLINE_BANKING.TRANSACTIONS;
RENAME TABLE ONLINE_BANKING.TRANSACTIONS_PPI AS ONLINE_BANKING.TRANSACTIONS;

相关内容

  • 没有找到相关文章

最新更新