Created
May 25, 2012 16:58
-
-
Save neilkod/2789194 to your computer and use it in GitHub Desktop.
export all rows where modified dt field is > 01-jan-2010
This file contains hidden or 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
exports data that was modified(inc. created) after a certain date, in this case 01-oct-2011 | |
uses analytic function to decide whether or not to add the column delimiter. in my case, i'm using || as a delimiter since my data contains tabs and commas | |
it generates /tmp/TABLE_NAME.cmd.sql and then executes it while spooling TABLE_NAME.txt. | |
usage: | |
$ sqlplus user/pass@db @export <TABLE_NAME> <MOD_DT_FIELD_NAME> | |
set echo off feedb off head off pages 0 lines 500 trimspool on verify off termout off array 1000 | |
alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'; | |
spool /tmp/&1..cmd.sql | |
prompt select | |
select lower(column_name)||case when column_id!=max(column_id) over (partition by table_name ) then ' || ''||'' ||' else null end col | |
from all_tab_columns | |
where table_name='&1' | |
order by column_id; | |
prompt from &1 | |
prompt where &2 >= TO_DATE('01-OCT-2011','DD-MON-YYYY') | |
prompt / | |
spool off | |
spool &1..txt | |
@/tmp/&1..cmd.sql | |
spool off | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment