I would want to generate create script that will create all the database views which are very many. I know how to do it in Oracle SQL Developer already using menu: Tools > Database Exports. However I encounter issues doing the export create views scripts. Below are the issues.
Issue #1 The order of creation of view is not correct. In example below, the MY_VIEW_B is created first in the script before its dependency MY_VIEW_A. How can I generate script that are in correct order of dependencies?
CREATE OR REPLACE MY_VIEW_B ("COLUMN1", "COLUMN2") AS
SELECT "COLUMN1", "COLUMN2"
FROM MY_VIEW_A;
CREATE OR REPLACE MY_VIEW_A ("COLUMN1", "COLUMN2") AS
SELECT "COLUMN1", "COLUMN2"
FROM TABLE_A;
Issue #2 The semicolon ";" is carried over to the last line of the view codes but the problem is it is comment line. So this will get error when I execute the script because there is no closing ";" semicolon since it was moved to the line where the comment is. How can I generate script so that the last line of my view code which is ";" semicolon is not auto carried over to second to the last line of the view code which is a comment?
CREATE OR REPLACE MY_VIEW_C ("COLUMN1", "COLUMN2") AS
SELECT "COLUMN1", "COLUMN2"
FROM TABLE_B
--THIS IS A COMMENT;
CREATE OR REPLACE MY_VIEW_C ("COLUMN1", "COLUMN2") AS
SELECT "COLUMN1", "COLUMN2"
FROM TABLE_C;
Thank you.
As Oracle States here:
also check
Terminator
andPretty Print
to deal with the second issue;Tested with
Oracle SQL Developer Version 4.1.3.20 Build MAIN-20.78