'Generate upgrade script to ALTER TABLE based on CREATE TABLE statement in Oracle [duplicate]

Is it possible in Oracle to generate a bunch of ALTER TABLE statements based on existing table in schema plus CREATE TABLE statement with newer definition of that table?

Let's say I have a schema with some previous version of an application. I have an installation script for newest version of the application. The script creates all tables and sequences from scratch performing CREATE TABLE (and probably CREATE SEQUENCE) statements.

I'd like to update the schema to the newest version of the application without loosing any data (e.g. without performing DROP TABLE).

Is it possible with using of standard Oracle 11gR2 or third party components?



Solution 1:[1]

You can create a procedure in PLSQL to:

  • create new table when it not exists in new DB
  • alter table when it exists, feeding it with ALL_TAB_COLUMNS

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matteo Rubini