REM Connect to SOURCE (src) database (schema)
CONNECT src_username/src_password@src_connect_identifier

SET ARRAYSIZE 1000
SET COPYCOMMIT 0
SET COPYTYPECHECK ON

REM Copy to TARGET (tgt) database (schema) - target table matching query definition must exist there
COPY TO tgt_username/tgt_password@tgt_connect_identifier -
INSERT tgt_tablename -
USING src_query
;