Oracle 表分区 函数列

create table TEST_PART2
(
  mobile        VARCHAR2(20) not NULL,
  servicecode   VARCHAR2(30) not NULL,
  servicefix VARCHAR2(100) GENERATED ALWAYS AS  (  
  CASE
    WHEN LENGTH(servicecode) = 1 THEN '00'||servicecode
    WHEN LENGTH(servicecode) = 2 THEN '0'||servicecode
    ELSE SUBSTR(servicecode,LENGTH(servicecode)-2)
  END   
  )VIRTUAL
)
PARTITION BY RANGE(servicefix)
(  
PARTITION part200000 VALUES LESS THAN('000') ,
PARTITION part200001 VALUES LESS THAN('001'),
PARTITION part200002 VALUES LESS THAN('100'),
PARTITION part200003 VALUES LESS THAN('999'),
PARTITION part200004 VALUES LESS THAN(MAXVALUE)
);

INSERT INTO test_part2(mobile,servicecode) VALUES('0', '0');
INSERT INTO test_part2(mobile,servicecode) VALUES('1', '1');
INSERT INTO test_part2(mobile,servicecode) VALUES('2', '10');
INSERT INTO test_part2(mobile,servicecode) VALUES('3', '19');
INSERT INTO test_part2(mobile,servicecode) VALUES('4', '000');
INSERT INTO test_part2(mobile,servicecode) VALUES('5', '1004');
INSERT INTO test_part2(mobile,servicecode) VALUES('6', '1014');
INSERT INTO test_part2(mobile,servicecode) VALUES('7', '1104');
INSERT INTO test_part2(mobile,servicecode) VALUES('8', '11004');
INSERT INTO test_part2(mobile,servicecode) VALUES('9', '12004');
INSERT INTO test_part2(mobile,servicecode) VALUES('10', '13004');

SELECT mobile,servicecode,servicefix,SUBSTR(servicecode,LENGTH(servicecode)-2) FROM test_part2 PARTITION(part200002)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值