Move column order Oracle 12c/18c/19c

      No Comments on Move column order Oracle 12c/18c/19c

Since the release of Oracle 12c it is now easier to move columns logically.

Oracle 12c added support for making columns invisible and that feature can be used to rearrange columns logically.

Quote from the documentation on invisible columns:

When you make an invisible column visible, the column is included in the table’s column order as the last column.

Example

Create a table:

CREATE TABLE test (
    a INT,
    b INT,
    d INT,
    e INT
);

Add a column:

ALTER TABLE test ADD (c INT);

Move the column to the middle:

ALTER TABLE test MODIFY (d INVISIBLE, e INVISIBLE);
ALTER TABLE test MODIFY (d VISIBLE, e VISIBLE);

DESCRIBE test;

Name
----
A
B
C
D
E

Leave a Reply

Your email address will not be published. Required fields are marked *