Unable to make a partition by range with ALTER TABLE in ORACLE

40 Views Asked by At

I have this attribute named category_, on which I'd like to partition my table named unicode. Here's the code :

alter table unicode (
    partition by range (category_) (
        partition p0 values less than ('Cc'),
        partition p1 values less than ('Cf'),
        partition p2 values less than ('Co'),
        partition p3 values less than ('Cs'),
        partition p4 values less than ('Ll'),
        partition p5 values less than ('Lm'),
        partition p6 values less than ('Lo'),
        partition p7 values less than ('Lt'),
        partition p8 values less than ('Lu'),
        partition default_ values less than (MAXVALUE)
)
); 

This doesn't work, citing "01735. 00000 - invalid ALTER TABLE option". I haven't been able to find anything of use in the ORACLE documentation.

Here's the table scheme :

create table unicode (
  codepoint nvarchar2(6) PRIMARY KEY,
  charname  nvarchar2(100) NOT NULL,
  category_ nchar(2) NOT NULL,
  combining number NOT NULL,
  bidi nvarchar2(3) NOT NULL,
  decomposition nvarchar2(100),
  decimal_ number,
  digit number,
  numeric_ nvarchar2(100),
  mirrored nchar(1) NOT NULL,
  oldname nvarchar2(100),
  comment_ nvarchar2(100),
  uppercase nvarchar2(6), 
  lowercase nvarchar2(6),
  titlecase nvarchar2(6),
  CONSTRAINT fk_upper FOREIGN KEY (uppercase) REFERENCES unicode(codepoint),
  CONSTRAINT fk_lower FOREIGN KEY (lowercase) REFERENCES unicode(codepoint),
  CONSTRAINT fk_title FOREIGN KEY (titlecase) REFERENCES unicode(codepoint)
)

What I am trying to do is to partition this database on each value of category_, as they are few of them. If there is an easier way, it would be much appreciated.

EDIT : When I add partition, I fall back on the other error I've seen during my tests :

alter table unicode add 
    partition p0 values ('Cc'),
    partition p1 values ('Cf'),
    partition p2 values ('Co'),
    partition p3 values ('Cs'),
    partition p4 values ('Ll'),
    partition p5 values ('Lm'),
    partition p6 values ('Lo'),
    partition p7 values ('Lt'),
    partition p8 values ('Lu') // we could continue for every category
;

The error is : "14020. 00000 - "this physical attribute may not be specified for a table partition"

*Cause: unexpected option was encountered while parsing physical attributes of a table partition; valid options for Range or Composite Range partitions are INITRANS, MAXTRANS, TABLESPACE, STORAGE, PCTFREE, and PCTUSED; only TABLESPACE may be specified for Hash partitions

*Action: remove invalid option(s) from the list of physical attributes of a table partition

*Comment: this error could have resulted from omission of a terminating (right) parenthesis following the list of partition descriptions"

1

There are 1 best solutions below

0
Ashwik On BEST ANSWER

@Nolann Boyere,

I have changed the syntax where I added the keyword 'MODIFY' to your query.

ALTER TABLE unicode MODIFY 
    PARTITION BY RANGE (category_) (
        PARTITION p0 VALUES LESS THAN ('Cc'),
        PARTITION p1 VALUES LESS THAN ('Cf'),
        PARTITION p2 VALUES LESS THAN ('Co'),
        PARTITION p3 VALUES LESS THAN ('Cs'),
        PARTITION p4 VALUES LESS THAN ('Ll'),
        PARTITION p5 VALUES LESS THAN ('Lm'),
        PARTITION p6 VALUES LESS THAN ('Lo'),
        PARTITION p7 VALUES LESS THAN ('Lt'),
        PARTITION p8 VALUES LESS THAN ('Lu'),
        PARTITION default_ VALUES LESS THAN (MAXVALUE)
); 

Below listed partition were created to the given table. enter image description here