Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

change size of a PK column

muttleychessJun 23 2016 — edited Jun 30 2017

Hi

    I must increase column size and format of the data in a table of all your foreign keys that reference to this PK



  CREATE TABLE TABLE_A

  (

    CODIGO  VARCHAR2(7 BYTE)                 NOT NULL,

    DESCRICAO    VARCHAR2(255 BYTE)               NOT NULL

  )

  CREATE UNIQUE INDEX TABLE_A_PK ON TABLE_A

(CODIGO);

ALTER TABLE TABLE_A ADD (

  CONSTRAINT TABLE_A_PK

  PRIMARY KEY

  (CODIGO)

  USING INDEX TABLE_A_PK

  ENABLE VALIDATE);

CREATE TABLE TABLE_B

(

  COLUMN_1                  NUMBER(15,4)       NOT NULL,

  COLUMN_2                  NUMBER(15,4)       NOT NULL,

  CODIGO                    VARCHAR2(7 BYTE)

  );

 

ALTER TABLE TABLE_B ADD (

  CONSTRAINT TABLE_B_FK

  FOREIGN KEY (CODIGO)

  REFERENCES TABLE_A (CODIGO)

  ENABLE VALIDATE); 

  There others 3 tables  TABLE_C, TABLE_D,TABLE_D. , ALL  have a column with reference the column CODIGO  of TABLE_A, and al have  index in the column  with FK

   I must change size of the column CODIGO  7  to 9  and put points , example

1111111    with  7  digits   will be  11.111.11 with 9 digits

1234567 with 9     digits  willbe   12.345.67 with 9  digits

what should I do first?
drop constraints or disable
I need to rebuild the indexes? like sweeping all indices foreign key, since it may have to do the same for other tables with the same situation

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

PL/SQL Release 11.2.0.4.0 - Production

CORE    11.2.0.4.0    Production

TNS for Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 - Production

This post has been answered by EdStevens on Jun 23 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2016
Added on Jun 23 2016
17 comments
4,303 views