SQL Tran Docs
  • Overview
    • About
    • Getting started
    • Object lifecycle
    • Why is there no AI inside?
    • Performance considerations
    • Security considerations
    • Assessment
    • Unlocking projects
    • Interface walk-through
    • Translation scenarios
    • Prerequisites for Azure Marketplace deployment
  • Emulation Scenarios
    • Emulation in SQL Tran
    • SQL Server to Fabric Warehouse
      • Data types
      • Case sensitivity
      • Cursors
        • Basic cursor loop
        • Cursor types
        • Fetch direction modes
        • Cursors in control flow
        • Nested cursors
        • Data modification cursors
        • Multiple cursors
        • Subqueries and filtering
      • Named procedure parameters
      • Result set limiting
      • MERGE statements
      • Computed columns
      • External tables
      • Materialized views
      • Identity columns
      • Unsupported system objects
    • Synapse Analytics to Fabric Warehouse
      • Emulations
      • Limitations
    • SQL Server to Synapse Analytics
    • Oracle to PostgreSQL
  • Project wizard
    • Source database
    • Target database
    • Wrapping up
  • Projects
    • Project list
    • Overview
    • Workspace
    • Reports
    • Tests
    • Scratch pad
    • Settings
      • Project name
      • Mapping
      • Database connections
    • Navigation
    • Object complexity
    • Static analysis
    • Translation errors
    • Exporting and importing projects
  • Workspace
    • Object tree
    • Data lineage
    • Code
    • Actions
      • Overriding source
      • Overriding target
      • Ignoring objects
  • Tests
    • Workflow
    • Configure SQL Tran
    • Connecting to databases
      • Fabric Warehouse
      • Synapse Dedicated SQL Pool
      • Azure SQL Database, Azure SQL Managed Instance, Microsoft SQL Server
    • Tables
    • Views
    • Procedures
    • Functions
    • Triggers
    • Performance tests
  • Scripter
    • About
    • Supported databases
    • SQL Server
    • Azure SQL
    • Synapse Dedicated Pool
    • Oracle
    • PostgreSQL
    • MySQL
Powered by GitBook
On this page
  1. Scripter

Oracle

-d, --database

The name of the database to script. This value is required.

-s, --server

Full path to the database in the cloud (database-identifier.database.windows.net). This value is required.

-p, --port

Default value is 1521.

-u, --username

--password

--mode

Connection mode can be one of the following:

  • SID

  • Service Name

Default value is SID.

--as

Connect as:

  • Standard

  • SysDBA

  • SysOPER

Default value is Standard.

CREATE OR REPLACE FUNCTION get_whole_database_ddl
   RETURN CLOB
IS
   l_script CLOB := EMPTY_CLOB();
   l_ddl    CLOB;
BEGIN

   FOR rec IN (
      SELECT owner, object_name, object_type
        FROM dba_objects
       WHERE object_type IN ('TABLE','VIEW','PROCEDURE','FUNCTION','TRIGGER','PACKAGE','PACKAGE BODY','TYPE')
         AND owner NOT IN ('SYSTEM','XDB') AND UPPER(owner) NOT LIKE '%SYS' AND UPPER(owner) NOT LIKE 'APEX\_%' ESCAPE '\'
       ORDER BY object_type, owner, object_name
   )
   LOOP
      BEGIN
         l_ddl := DBMS_METADATA.GET_DDL(object_type => rec.object_type, name => rec.object_name, schema => rec.owner);
         l_script := l_script || TRIM(l_ddl) || CHR(10) || '/' || CHR(10);
      EXCEPTION
         WHEN OTHERS THEN
            l_script := l_script || '-- ERROR: ' || rec.object_type || ' ' || rec.owner || '.' || rec.object_name || ': ' || SQLERRM || CHR(10) || CHR(10);
      END;
   END LOOP;

   RETURN l_script;
END;

Create the procedure, then execute it in a decent client:

SELECT get_whole_database_ddl;

Ensure that your client doesn't truncate the output.

For example, DBeaver has a setting "Maximum text editor content length". Increase it.

SQL Developer actually needs to spool that to a file:

SET LONG 1000000000            -- allow very large output
SET LONGCHUNKSIZE 32767        -- size of each chunk
SET PAGESIZE 0                 -- suppress page headings
SET LINESIZE 32767             -- avoid wrapping

SPOOL C:\path\to\whole_db_ddl.sql
SELECT get_whole_database_ddl;
SPOOL OFF

PreviousSynapse Dedicated PoolNextPostgreSQL

Last updated 4 months ago