Created
June 12, 2024 07:40
-
-
Save dcdh/1dfe2a3f33d0af6e9c5dc402ccc2ec1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo SET PAGESIZE 0&echo SET LONG 5000&echo SET ECHO OFF&echo SET FEEDBACK OFF&echo SET HEADING OFF&echo SET LINESIZE 32767&echo SPOOL C:\path\to\export\all_tables_ddl.sql&echo @echo off&echo for /f "tokens=*" %%a in ('sqlplus -s username/password@database @ - ^<^<EOF | |
echo SET PAGESIZE 0 | |
echo SET LONG 5000 | |
echo SET ECHO OFF | |
echo SET FEEDBACK OFF | |
echo SET HEADING OFF | |
echo SET LINESIZE 32767 | |
echo DECLARE | |
echo CURSOR tables_cur IS | |
echo SELECT table_name | |
echo FROM user_tables; | |
echo BEGIN | |
echo FOR table_rec IN tables_cur LOOP | |
echo DBMS_OUTPUT.PUT_LINE(DBMS_METADATA.GET_DDL('TABLE', table_rec.table_name)); | |
echo END LOOP; | |
echo END; | |
echo / | |
echo EOF | |
echo ') do @echo %%a >> C:\path\to\export\all_tables_ddl.sql'&echo SPOOL OFF&echo EXIT | cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@echo off
echo SET PAGESIZE 0 > temp.sql
echo SET LONG 5000 >> temp.sql
echo SET ECHO OFF >> temp.sql
echo SET FEEDBACK OFF >> temp.sql
echo SET HEADING OFF >> temp.sql
echo SET LINESIZE 32767 >> temp.sql
echo SPOOL C:\export\all_tables_ddl.sql >> temp.sql
echo DECLARE >> temp.sql
echo CURSOR tables_cur IS >> temp.sql
echo SELECT table_name >> temp.sql
echo FROM user_tables; >> temp.sql
echo BEGIN >> temp.sql
echo FOR table_rec IN tables_cur LOOP >> temp.sql
echo DBMS_OUTPUT.PUT_LINE(DBMS_METADATA.GET_DDL('TABLE', table_rec.table_name)); >> temp.sql
echo END LOOP; >> temp.sql
echo END; >> temp.sql
echo / >> temp.sql
echo SPOOL OFF; >> temp.sql
echo EXIT; >> temp.sql
sqlplus -s scott/tiger@orcl @temp.sql