✅ Option 1 — Use bcp out with a filtered query (recommended)
Sybase bcp supports exporting results of a SQL query, not just entire tables.
Example: dump last 45 days from table MYTABLE with timestamp column INTERNTIMESTAMP.
bcp "select * from MYTABLE
where INTERNTIMESTAMP >= dateadd(dd, -45, getdate())"
queryout mytable_45days.dat -c -U user -P pass -S server
Notes:
queryout lets you export results of a query.
-c uses character mode (good for Oracle import).
Make sure dateadd() and getdate() match your Sybase SE syntax (SQL Anywhere uses dateadd('day', -45, now())).
For SQL Anywhere (Sybase SE):
dbisql -c "uid=user;pwd=pass;eng=mydb" ^
"select * from MYTABLE
where INTERNTIMESTAMP >= dateadd( day, -45, current timestamp )"
mytable_45days.csv
or using dbunload with -x and -s filters (below).
✅ Option 2 — SQL Anywhere: Use dbunload with row filter
SQL Anywhere (Sybase SE) has a flexible unload tool:
dbunload -c "uid=user;pwd=pass;dbf=my.db" ^
-s "select * from MYTABLE where INTERNTIMESTAMP >= dateadd(day, -45, current timestamp)" ^
myexportdir
This creates:
mytable.sql with table schema,
mytable.dat with only filtered rows.
Perfect for Oracle import.
❌ What you cannot do
You cannot run:
dump database ... where time > ...
You cannot dump one table
You cannot dump only 45 days using native dump commands
Dump is for full DB backup only.
👍 Best practice for Oracle transfer
Use bcp queryout or dbunload -s to extract filtered data.
Load into Oracle using:
SQL*Loader
External table
INSERT /*+ APPEND */ from CSV
Top comments (0)