Import/Export an oracle db/schema
Prerequisites:
- Import:
- Oracle DB setup with default DB
- the username that has access to the import DB
- Remember to set the character set if importing Unicode
- Import/Export:
- ip-address, SID, user/pass (sysDBA)
To export/import a DB using telnet/linux console:
- Set the environment variables (should exist)1234567
<span style="text-decoration: underline;">Linux</span>:$ORACLE_HOME =/u01/app/oracle/product/10.2.0/db_1/bin$ORACLE_SID = myoracl$PATH =/u01/app/oracle/product/10.2.0/db_1/bin<span style="text-decoration: underline;">Windows</span>:SET NLS_LANG=AMERICAN_AMERICA.ELI8MSWIN1253 - Startup the DB (if needed)1
sqlplus/nologSQL prompt:
123connectuser/passassysdbastartupexit - Startup the listener (if needed)12
cdto oracle app product path ($ORACLE_HOME/bin)./lsnrctlstart - Startup the em console (web interface, if needed)1
./emctlstart - Export data
- entire database:1
exp dbuser/passwordFULL=y FILE=exportDB.dmp LOG=exportDB.log - schema only:1
exp dbuser/passwordFIlE=scott.dmp OWNER=scott
- entire database:
- Importdata
- if needed, create the user for the DB:123456789
CREATEUSERusername IDENTIFIEDBY"username"DEFAULTTABLESPACE"USERS"TEMPORARYTABLESPACE"TEMP"PROFILEDEFAULTQUOTA UNLIMITEDON"USERS";GRANT"CONNECT"TOusername;GRANT"DBA"TOusername;GRANTCREATEsessiontousername;ALTERUSERusernameDEFAULTROLE NONE; - login with new user and try an sql statement:1
selectsysdatefromdual; - entire database:1
imp dbuser/passwordFULL=y FILE=exportDB.dmp LOG=importDB.log - schema only:1
imp dbuser/passwordFIlE=scott.dmp
Notes:
– If you get an error that the export was not done by the user doing the import, you need to do it with theuser who actually exported the .dmp file.
– If you get an error trying to import and it stops, you may need to add: dbuser/password@db - if needed, create the user for the DB:
import/export tables only:
- Export tables [emp] and [dept] from "scott" user:1
exp dbuser/passwordFILE=scott.dmp TABLES=(emp,dept) - Import tables [dept] and [emp] from "scott" user:1
imp dbuser/passwordFIlE=importDB.dmp FROMUSER=scott TABLES=(dept,emp)