How can I use imp command with REMAP_TABLESPACE? - oracle

With Oracle 11g, how can I use imp command to import schema from a different database that was already exported to a dmp file and which its tablespace needs to be renamed during the import?
I understand that there's a REMAP_TABLESPACE command but I only found how to use it with impdp and I need System DBA privileges for that, and I don;t have it.
Thanks

We closed this issue with one of our DBAs to refresh the schema with the relevant data, but yes it seems that impdp/expdp was the best way if we had the permissions.
Thanks for all the help.

Related

Oracle expdp and impdp command?

I want to know the Oracle expdp and impdp command for sys user and scott/tiger user for entire database or a particular table.I will be grateful if you share me the script of expdp and impdp.I also want the script of recovery of a entire database and performance tuning.
There is no such "the" script, as in one single script that does whatever you seem to wan. If you want to know how to use expdp and impdp, then check the documentation - the Utilities manual.
And to address one point, using expdp/impdp as SYS, the manual specifically warns against it, with this quote:
Note:
Do not start Export as SYSDBA, except at the request of Oracle
technical support. SYSDBA is used internally and has specialized
functions; its behavior is not the same as for general users.
And there is no single script for " recovery of a entire database". Recovery of an entire database should actually be done with rman, using backups made by rman, not expdp.
And there is certainly no script for "performance tuning." You are looking for simplistic answers to complex issues. Whole books have been written on performance tuning. Performance tuning depends on identifying the cause of poor performance, and that can come from countless unrelated sources.
Before exporting/importing a dump of the database make sure that you have created a directory and give the permissions to read & write on this for the user that will be used to export/import.
Some basic examples for expdp & impdp:
full database export: expdp scott/tiger#orcl directory=mydir dumpfile=expdp_full_db.dmp logfile=expdp_full_db.log full=YES;
table export: expdp scott/tiger directory=mydir dumpfile=table_exp.dmp logfile=table_exp.log table=test
table import: impdp scott/tiger directory=mydir dumpfile=table_exp.dmp logfile=table_exp.log tables=test
These are just some examples. Expdp and impdp provide a lot more useful options and parameters. More details here (https://oracle-base.com/articles/10g/oracle-data-pump-10g )
But keep in mind that EdStevens is right because there is not a 'script' that can be used to solve any problem, especially performance issues.

Impdp overwrite source data

I'm pretty new in Oracle and I need some help.
I wanna dump some tables from STAT user to ALLSTAT.
STAT got imp_full_database privelege, ALLSTAT got exp_full_database one, no dba privileges.
I'm testing impdp on my localhost, so NETWORK LINK was created like this:
CREATE DATABASE LINK transport CONNECT TO STAT IDENTIFIED BY STATPASS USING '127.0.0.1:1521/XE';
Than i try in cmd:
impdp ALLSTAT/ALLSTATPASS#XE NETWORK_LINK=transport TABLES=STAT.LOGS CONTENT=ALL TABLE_EXISTS_ACTION=REPLACE;
I got no error messages, but after this script, i got empty LOGS table on STAT user.
In my opinion, during impdp, it trying to import data into table not ALLSTAT.LOGS but STAT.LOGS which are exported.
I can see, edit, drop STAT.* tables even if i logged as ALLSTAT user.
Could you tell me, which way should i go to get ALLSTAT own table LOGS with data from STAT.LOGS?
P.S. Sorry for my English :(
Founded a solution.
impdp ALLSTAT/ALLSTATPASS#XE NETWORK_LINK=transport TABLES=STAT.LOGS CONTENT=ALL TABLE_EXISTS_ACTION=REPLACE REMAP_SCHEMA=STAT:ALLSTAT;
REMAP_SCHEMA=STAT:ALLSTAT is required,
thx to #davegreen100
impdp command with TABLE_EXISTS_ACTION=REPLACE works for me.

Oracle 11g IMP functionality

Just looking for a little clarification on Oracle 11g imports.
I have a user that DOES have privileges to import & a second user that DOESN'T have privileges to import, I was basically wondering if I can use the user that does have privileges to import into the shemea for the user the does not.
So if for example:
User CANIMP does have privileges
User NOIMP does not have privileges
Would this import into the user that does not?
imp CANIMP/password123#localhost/ORCL file=my_dumpfile.dmp fromuser=CANIMP touser=NOIMP log=import_details.log
The FROMUSER parameter is the schema owner of the exported data. It seems unlikely that this is the CANIMP user, but perhaps it is.
If in fact the export structures already belong to NOIMP you do not need to specify TOUSER. You only need to specify the TOUSER if you are changing the owning schema from the export. This has nothing to do with the user running the import job.
Incidentally, you're on 11g, so why are you still using IMP ? The IMP and EXP utilities have been deprecated in favour of DATAPUMP for a long time now. Find out more.

Oracle: Recover backup in other different than original server

I'm really newbie about Oracle backup operations. I'm really new in this world and I need to know how to backup a DB schema and restore it in another machine under another schema name.
I cannot afford any mistake since I'll be doing this in our customer site, an making a small mistake could be the last one
I don't want to sound offensive, but doing this in MySQL is really easy, like this:
in server one:
$mysqldump --user=user --password=password db_to_backup > bc_name.sql
-after transfering the sql script to another server
in server two:
mysql>create database db_to_restore;
$mysql --user=user --password=password db_to_restore < bc_name.sql
I need to do the same using Oracle, I read some documentation but I'm still unsure how to do it:
First: What's the equivalent of MySQL database in Oracle? tablespace?
Second: I think these are the steps to get a backup
mkdir /opt/oracle/dumptmp/
CREATE OR REPLACE DIRECTORY dumptmp AS '/opt/oracle/dumptmp/';
expdp user/pass#tablespace directory=dumptmp dumpfile=dumptmp:full.dmp logfile=dumptmp:full.log full=y
Third: Then I move the file "full.dmp" to the other server, but I'm not sure how to restore my backup file full.dmp into a new tablespace with a different name to the one it the backup was gotten from:
SQLPLUS>create tablespace ts_something;
then I'm not sure how to proceed from here. Please advice me how to do it using command line commands since my customer does not have GUI tools intalled.
Thanks a lot!
First of all, make sure you test this procedure in test or development environments before proceeding to perform it on production. Disclaimer: I'm not responsible if you bust any of your databases by misusing the following advice. Note that I'm also ignoring how tablespace storage is set up for your schemas, which you should definitely hold in consideration when creating new schemas.
Here is the simplest possible method using command line. You will need to use exp and imp utilities which come with complete Oracle database distributions. Assuming that you have the path to Oracle executables set correctly in your environment path, you will need to do:
Export your source schema on the source database server:
[oracle#src_server ~]$ exp source_schema_username#SRC_SID owner=source_schema_username file=source_schema.dmp
Import your source schema into destination schema on the destination database server (assuming you have already created the destination schema, if not, see CREATE USER, also make sure that destination schema user has RESOURCE role):
[oracle#dst_server ~]$ imp system#DST_SID fromuser=source_schema_username touser=destination_schema_username file=source_schema.dmp
Note that you must run imp as a user that has DBA role. I'm using system here because this user typically exists on all Oracle databases and has DBA role. You will of course need to know the password for system user. You may not need to specify SIDs if ORACLE_SID is already set in your environment on both servers (echo $ORACLE_SID), however I wanted to be explicit here to make sure that you do not import into the wrong database.
For more information on usage of export and import utilities run exp help=y and imp help=y.
To answer your questions about Oracle:
First: What's the equivalent of MySQL database in Oracle? tablespace?
Oracle equivalent is database name (db_name parameter). It identifies a database on Oracle database server(s). On a single instance database, this is also typically Oracle SID. On Oracle RAC, a single database will have many SIDs.
Third: Then I move the file "full.dmp" to the other server, but I'm not sure how to restore my backup file full.dmp into a new tablespace with a different name to the one it the backup was gotten from:
You want to create a new user, which is identical to a schema in Oracle. Tablespaces are abstracted collections of disk locations where Oracle stores tables and indicies. For example, when you create a table, it has to be assigned to some tablespace.
What you're explaining is not really a backup, more like schema export & import.
but doing this in MySQL is really easy.
So is doing the same in Oracle.
exp user/password#hoststring file=bc_name.dmp log=bc_name.log full=y statistics=none
& to import it,
imp new_user/new_password#hoststring file=bc_name.dmp log=bc_name.log full=y
If new_user doesn't exist then create the users
create user new_user identified by new_password
and grant the rights
grant create session,connect,imp_full_database to new_user

clone oracle database without data

I want to clone my existing oracle database structure without data including packages, users, tablespaces etc. I read some methods but they all copied data as well. Is there anyway out in order to do this?
Thanks in advance.
Use SQL Developer > Tools > Database Export..
On "Specify Data" do not include any tables.
Omit packages etc here,
Fine tune your selection here,
My trial export has not finished yet but I expect this will work.
Use Oracle exp.exe utility for export. E.g.
EXP.EXE login/password#TNSNAME file=entire_db.dmp owner=(scott, my_user, user2) rows=n grants=y triggers=y
Only rows=n option in command above make sense for your task.
You can import to target database with imp.exe utility.
Look for detailed option list and definition by running this utilities with help=y option.
BUT tablespaces and users on target databases must be created manually before running import.
There are no standard tablespace cloning tools (including SQL Developer), but some queries exists for generating such cloning scripts.
Examples can be found here and here.
P.S. This question better fits to ServerFault than to StackOverflow ...
You can do it in toad but its not free tool. (Database Tab->Export->Export DDL)
Try Oracle Export command with ROWS=N
exp SCOTT/TIGER ROWS=N TRIGGERS=N
Use SQL Developer, Tools > Database Export.
You will need to specify at least one table in the 'data' option because you cannot choose to NOT export any data. Pick a table that has a small number of rows or create a dummy table without any rows beforehand as a workaround.

Resources