Skip to content

Instantly share code, notes, and snippets.

@antonmry
Last active August 29, 2015 14:07
Show Gist options
  • Save antonmry/9ddc1f6088a656b9237b to your computer and use it in GitHub Desktop.
Save antonmry/9ddc1f6088a656b9237b to your computer and use it in GitHub Desktop.
Oracle database commands

Create user

$ ORACLE_SID=XE sqlplus /nolog
SQL> connect / as sysdba;
SQL> CREATE USER username IDENTIFIED BY apassword;
SQL> GRANT CONNECT TO username;
SQL> GRANT CREATE SESSION TO username;
SQL> GRANT CREATE TABLE TO username;
SQL> GRANT UNLIMITED TABLESPACE TO username;

Import DB with Oracle Datapump

$ ORACLE_SID=XE sqlplus /nolog
SQL> connect / as sysdba;
SQL> CREATE USER TORPEMP IDENTIFIED BY TORPEMP;
SQL> GRANT CONNECT TO TORPEMP;
SQL> GRANT CREATE SESSION TO TORPEMP;
SQL> GRANT CREATE TABLE TO TORPEMP;
SQL> GRANT UNLIMITED TABLESPACE TO TORPEMP;
SQL> CREATE OR REPLACE DIRECTORY test_dir AS '/home/oracle/db';
SQL> GRANT READ, WRITE ON DIRECTORY test_dir TO TORPEMP;
SQL> create tablespace TSTORPEMP_DATA datafile '/home/oracle/db/TSTORPEMP_DATA.dbf' size 50m ;

$ cp *.dmp *.log /home/oracle/db
$ ORACLE_SID=XE impdp TORPEMP/TORPEMP directory=TEST_DIR full=Y dumpfile=exp_torpemp_03-11-2014.dmp logfile=exp_torpemp_03-11-2014.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment