Get table and index DDL the easy way

set heading off;
set echo off;
Set pages 999;
set long 90000;

spool ddl_list.sql

select dbms_metadata.get_ddl('TABLE','DEPT','SCOTT') from dual;


# funcy spool file name
COLUMN system_date NEW_VALUE YYYYMMDD
SELECT to_char(sysdate,'YYYYMMDD') system_date FROM DUAL;

spool myspool_&&YYYYMMDD..log


select dbms_metadata.get_ddl('INDEX','DEPT_IDX','SCOTT') from dual;

spool off;