Remember, one thing Datapump doesn't do (by design) is recreate grants to objects owned by SYS.\\
If the user does not yet exist on the destination database, just import it using the procedure outlined [[Data Pump|here]].\\
Or if you are asked to create a user 'like' another user, use this:
$ expdp schemas=CURRENTUSER content=metadata_only
$ impdp remap_schema=CURRENTUSER:NEWUSER
If however, the user(schema) already exists, it will have to be dropped and re-created before the data can be imported.\\
Run [[Extract ddl with "dbms metadata.get ddl"#Get User DDL with related grants|this script]] to generate the recreation DDL\\
After this has been run, the following command can be executed:
drop user cascade;
Now, recreate the schema with the above-mentioned DDL\\
The dumpfile (or a part thereof) can now be imported to fill up the currently empty schema:
impdp / parfile=schema.par
where schema.par would look like this:
directory=DATA_PUMP_DIR
dumpfile=.DMP
schemas=()
and/or maybe one or more of the following:
exclude=grants
tables=(.)
remap_tablespace=old:new
Finally, recompile all invalid objects:
exec utl_recomp.recomp_serial();
or
exec utl_recomp.recomp_parallel(4);
or
@?\\rdbms\\admin\\utlrp.sql
or
@?\\rdbms\\admin\\utlprp.sql(4)