Skip to Main Content

SQL & PL/SQL

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!

Need inputs to create a oracle view with union selects added using a procedure

user9977206Jun 1 2021

We have multiple schemas in the Oracle database with the same table name.
All the tables have the exact same structure (both column names and types). I want to create a view to Union them together. In addition, there will be new tables of the same type that will be added later into the database, so I need the view to be able to 'run through' all existing tables in the database and add them (either adding or creating the view from scratch).
I've created a simple view with the table's name's hardcoded but I'm having difficulty how to approach the issue of having the view created dynamically. I'm using Oracle 19c
I assumed I'll probably have to write some script code that would actually run and check for new table names but I wanted to see some example to figure out how to do that.

In an Oracle procedure, how can we create the view adding the union selects dynamically?

Comments
Post Details
Added on Jun 1 2021
3 comments
520 views