Oracle expdp/impdp with query condition and between two schemes

In this example we will do export of one table but with data only (without metadata – constraint, index, trigger, statistics, grants) but only for specific date range (older than 01/01/2017)  based on date in some table column and then import of that ranged table to some other scheme/user.
If source and destination scheme/user are in different tablespaces or you want to append data in table in case of table already exists – you have syntax bellow.
We don’t use parameter CONTENT=DATA_ONLY because in that case – table cannot be automatically created in another scheme (usable only for existing tables).

For easier work we will use user variables in this case and we will do this in Linux server.

####################################
########### VARIABLES ##############
SOURCE_USER="kompjuteras"
SOURCE_PASS="kompjuteras_pass"
SOURCE_TABLE_FOR_EXPORT="some_table"
SOURCE_TABLE_DATE_COLUMN_NAME="table_date"
DESTINATION_USER="other_user"
DESTINATION_PASSWORD="other_user_pass"
DATAPUMP_FOLDER="DIR_FOR_EXPORT"
####################################

# Export only table data and specific date range
expdp ${SOURCE_USER}/${SOURCE_PASS} \
tables=${SOURCE_TABLE_FOR_EXPORT} \
directory=${DATAPUMP_FOLDER} \
query=${SOURCE_TABLE_FOR_EXPORT}:\"where ${SOURCE_TABLE_DATE_COLUMN_NAME} \< \'01-JAN-2017\'\" \
dumpfile=`date +%Y-%m-%d`_${SOURCE_TABLE_FOR_EXPORT}.dmp \
logfile= `date +%Y-%m-%d`_${SOURCE_TABLE_FOR_EXPORT}.export.log \
exclude=constraint,index,trigger,statistics,grants

# Import data to table in another scheme
impdp ${DESTINATION_USER}/${DESTINATION_PASSWORD} \
directory=${DATAPUMP_FOLDER} \
dumpfile=`date +%Y-%m-%d`_${SOURCE_TABLE_FOR_EXPORT}.dmp \
logfile= `date +%Y-%m-%d`_${SOURCE_TABLE_FOR_EXPORT}.import.log \
tables=${SOURCE_TABLE_FOR_EXPORT} \
REMAP_SCHEMA=${SOURCE_USER}:${DESTINATION_USER}

# if needed REMAP_TABLESPACE=SOURCE_TABLESPACE:DESTINATION_TABLESPACE
# if needed TABLE_EXISTS_ACTION=APPEND