$ export ORACLE_SID=orcl
$ ORAENV_ASK=NO
$ . oraenv
$ ORAENV_ASK=YES
$ sqlplus / as sysdba
-- Create a directory to export to.
-- This directory should be created in the 12c database too.
CREATE OR REPLACE DIRECTORY TEMP_DIR AS '/tmp/';
-- Create a new tablespace and test user with some dummy data.
CREATE TABLESPACE data_ts
DATAFILE '/u01/app/oracle/oradata/orcl/data01.dbf' SIZE 1M
AUTOEXTEND ON NEXT 1M;
CREATE user test IDENTIFIED BY test
DEFAULT TABLESPACE data_ts
TEMPORARY TABLESPACE temp
QUOTA UNLIMITED ON data_ts;
GRANT CREATE SESSION, CREATE TABLE TO test;
CREATE TABLE test.t1 AS
SELECT * FROM dba_objects;
-- Make the tablespaces you want to transport read-only.
ALTER TABLESPACE data_ts READ ONLY;
ALTER TABLESPACE example READ ONLY;
EXIT
Export the database, using the "FULL=Y TRANSPORTABLE=ALWAYS VERSION=12
" parameters. I excluded the "USER" tablespace as it was already present in the 12c database and there was nothing I wanted to transfer in that tablespace.
$ expdp system full=Y transportable=always version=12 directory=TEMP_DIR \
dumpfile=orcl.dmp logfile=expdporcl.log exclude=TABLESPACE:\"= \'USERS\'\"
The export contains just metadata for the data tablespaces, but includes the normal dump contents of the SYSTEM and SYSAUX tablespaces.
Copy the datafiles to the correct location for the 12c database.
$ cp /u01/app/oracle/oradata/orcl/data01.dbf /u01/app/oracle/oradata/orcl12c
$ cp /u01/app/oracle/oradata/orcl/example01.dbf /u01/app/oracle/oradata/orcl12c
At this point it probably makes sense to switch the tablespaces back to read-write and shutdown the 11g database.
$ sqlplus / as sysdba
ALTER TABLESPACE data_ts READ WRITE;
ALTER TABLESPACE example READ WRITE;
SHUTDOWN IMMEDIATE;
EXIT;
We can now import the dump file into the 12c database. This of course assumes you have already created the directory object in the 12c database, as mentioned previously.
$ export ORACLE_SID=orcl12c
$ ORAENV_ASK=NO
$ . oraenv
$ ORAENV_ASK=YES
$ impdp system full=Y directory=TEMP_DIR dumpfile=orcl.dmp logfile=impdporcl.log \
transport_datafiles= \
'/u01/app/oracle/oradata/orcl12c/data01.dbf', \
'/u01/app/oracle/oradata/orcl12c/example01.dbf'