SQL developer - script export templete

Viewed 14

When I export a SQL script from SQL developer (right click on DB entity like VIEW then "Quick DDL->Save to file" in context menu), SQL developer exports its SQL code with some prefixed comment like:

--------------------------------------------------------
--  File created - srijeda-rujna-21-2022   
--------------------------------------------------------
--------------------------------------------------------
--  DDL for View THE_NAME_OF_MY_VIEW
--------------------------------------------------------

How can I change this (where is the template that SQL developer uses for this export)?

1 Answers

It's not anywhere you can get access to it, to change. So if you don't like it, generate the DDL yourself.

Thankfully, SQL Developer makes this easy with the 'DDL' command.

Simply do this in a SQL worksheet and run as a Script (F5)

ddl emp_details_view -- sub your view name, obviously

And the output, from our HR schema:

CREATE OR REPLACE FORCE EDITIONABLE VIEW "HR"."EMP_DETAILS_VIEW" ("EMPLOYEE_ID", "JOB_ID", "MANAGER_ID", "DEPARTMENT_ID", "LOCATION_ID", "COUNTRY_ID", "FIRST_NAME", "LAST_NAME", "SALARY", "COMMISSION_PCT", "DEPARTMENT_NAME", "JOB_TITLE", "CITY", "STATE_PROVINCE", "COUNTRY_NAME", "REGION_NAME") DEFAULT COLLATION "USING_NLS_COMP"  AS 
          SELECT
          e.employee_id,
          e.job_id,
          e.manager_id,
          e.department_id,
          d.location_id,
          l.country_id,
          e.first_name,
          e.last_name,
          e.salary,
          e.commission_pct,
          d.department_name,
          j.job_title,
          l.city,
          l.state_province,
          c.country_name,
          r.region_name
        FROM
          employees e,
          departments d,
          jobs j,
          locations l,
          countries c,
          regions r
        WHERE e.department_id = d.department_id
          AND d.location_id = l.location_id
          AND l.country_id = c.country_id
          AND c.region_id = r.region_id
          AND j.job_id = e.job_id
        WITH READ ONLY;

And if you want that in a file, just add this directly before the DDL

 cd c:\path\to\file
 spool view.sql
Related