IMPDP in Oracle 11g - From One Schema to other Schema - oracle

I used to run commands to get Oracle database backup in the old way using 'exp' and 'imp fromuser touser. Now, I am trying to user new command to take backup 'expdp' and 'impdp'.
Steps:
Got backup using expdp with schema parameter on the production server. my username is 'xxx' (Not sure it's fully exported with procedures, function, and view).
Now, on my dev server first I made another user called 'yyy'. I gave directory access to user 'yyy' and trying to run command impdp as below.
C:\impdp yyy/yyy remap_schema=xxx:yyy directory=abc dumpfile=123.dmp logfile=123.log
Now, I am getting an error like the below.
Import: Release 11.1.0.6.0 - Production on Thursday, 24 January, 2013 9:53:58
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining, and Real Application Testing options
ORA-31626: job does not exist
ORA-31633: unable to create master table "yyy.SYS_IMPORT_FULL_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 978
ORA-01031: insufficient privileges
Do I miss any steps? like I have to create a job or anything, not sure. basically, I got backup from one user and need to restore on another user in Oracle.
Please help me.

User yyy will need appropriate privledges necessary to create the objects.
See: privileges required to import objects into your own schema.
http://docs.oracle.com/cd/E11882_01/server.112/e22490/original_import.htm#BABFHCBI
Also:
http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_overview.htm#CJAIBFJG
Many Data Pump Export and Import operations require the user to have the DATAPUMP_EXP_FULL_DATABASE role and/or the DATAPUMP_IMP_FULL_DATABASE role. These roles are automatically defined for Oracle databases when you run the standard scripts that are part of database creation. (Note that although the names of these roles contain the word FULL, these roles are actually required for all export and import modes, not only Full mode.)
The DATAPUMP_EXP_FULL_DATABASE role affects only export operations. The DATAPUMP_IMP_FULL_DATABASE role affects import operations and operations that use the Import SQLFILE parameter. These roles allow users performing exports and imports to do the following:
•Perform the operation outside the scope of their schema

I believe, import user donot have permission on import database directory.
In the Import db,
select directory_name,directory_path from dba_directories;
It will show the directory names
sql>grant read,write on directory abc to ;
Robertson
Oracle Database SME
+91-9886321339

Related

insufficient privileges SYS.DBMS_DDL

I am trying to use the Oracle imp utility. A lot of good documentation exists but it seems that it is not possible or documented how to import with a regular user. It is assumed that sys will be used I think. Grant privileges for example using something like
GRANT execute ON sys.dbms_ddl TO myuser;
Which is suggested on some non-Oracle sites. Does not work. The error remains the same.
IMP-00003: ORACLE error 1031 encountered
ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_DDL", line 361
What grants should I issue to authorize a user for imp utility?
Importing as SYSTEM also does not work. This user also does not have permissions to import.
[vagrant#jira ~]$ imp SYSTEM/oracle#jira file=/tmp/jira-oracle.dmp fromuser=jira touser=jira_restore
Import: Release 12.2.0.1.0 - Production on Tue Oct 9 12:24:09 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
Export file created by EXPORT:V12.02.00 via conventional path
import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
IMP-00003: ORACLE error 942 encountered
ORA-00942: table or view does not exist
IMP-00023: Import views not installed, please notify your DBA
IMP-00000: Import terminated unsuccessfully
Has anyone used these utilities with some success? I don't think they are officially supported by Oracle.
They are shipped by Oracle strange enough. On Oracle website
Instant client tools provides exp / imp utilities since v12.2.0.1.0.
Unrestricted download is available
But also on the documentation website of Oracle
Original export is desupported for general use as of Oracle Database
11g
So it seems it can be both: distribute tools but not support them!
So I am reaching a conclusion here. Simple export / import of a schema is not so simple if at all possible when using Oracle. Contrary to statements made.
Maybe the file you are trying to import constains objects that you have no permission to create/alter.
try this:
GRANT IMP_FULL_DATABASE TO myuser;
or run the IMP utility as SYSTEM user (not the SYS, but SYSTEM).

Using Oracle "Create User" command does not automatically create an associated schema

I'm just getting started with Oracle data export and import and things worked perfectly fine the first time around. But then I came back next day repeated the exact same steps on the same systems, but get ORA-01435: user does not exist error.
System Specs for all machines:
-OS: Windows 2012 R2 x64
-Oracle Server: Oracle 11G Express x64
Objective:
I'm exporting data from Oracle server 1 and importing to Oracle server 2.
Procedure:
Export data dump is successful from Oracle server 1.
but when importing the data dump on Oracle server 2, I follow this procedure:
-Stop IIS service
net stop WAS
Create Schema/user account and Grant privileges before import
net stop WAS
sqlplus / as sysdba;
CREATE user PIE1 identified by PASS1;
GRANT ALL PRIVILEGES TO PIE1;
GRANT IMP_FULL_DATABASE TO PIE1;
According to oracle, all goes well, but look at the first image bellow. In DBeaver, I can see that only the User account PIE1 has been created, but NO schema.
Oracle issue 1. User account created, but not the Schema
Question 1: According to Oracle, the command "Create User" IS supposed to also create an associated Schema. Anyone have an idea why this is no longer working for me? It worked once the night before.
I then continue the import procedure as follows:
imp PIE1/PASS1#xe file=c:\Backups\AVUSER2_6_7.dmp log=c:\Backups\import.log fromuser=AVUSER2_6_7 touser=PIE1;
But get the following error:
Oracle claims the User doesn't exist even though it does
Oracle claims the User doesn't exist even though it does. I repeated the entire procedure and even created an identical import/export user account and credentials, and this error still comes up.
Question 2: Any idea why Oracle "Can't find" a user account that's clearly in the database?
Additional Info:
Checked that my windows account is in admin group
Checked that my windows account is in ORA_DBA group
Opened all CMD prompt as Admin
As you implied, users and schemas as the same in Oracle, you can't have a user without a schema. No idea about DBeaver, but as there are other users that aren't listed under 'schemas' (according to your second image - ANONYMOUS, DIP, ...) that seems to be unrelated.
(Purely a guess, but perhaps the user you're connect as in DBeaver just doesn't have visibility of any objects owned by those users - maybe it only lists users it can see in all_objects, say. Pure speculation, but you could investigate that by looking at the data dictionary while connect through SQL*Plus as the same user. According to this old forum post, there is an option to hide empty schemas...)
The import is connecting successfully as PIE1 - you'd get a different error, ORA-01017, if it wasn't and you wouldn't see the 'Connected to...' banner or anything after that.
Your import command has a trailing semicolon that should not be there. The "importing ... objects into" message shows that it's trying to import into the PIE1; user and not the one you actually created, PIE1. Remove that semicolon and try again.
Incidentally, you can probably also remove the #xe TNS alias and stick to a local connection, assuming the environment is configured as it was whenyou ran SQL*Plus. You should also consider using datapump expdp/impdp rather than the legacy exp/imp.

impdp in Oracle. Why it does not create users?

I am newbie in oracle and I am facing troubles with impdp. I have a production server and I have created a new server for testing purposes, so I installed centos, oracle and created the database "sire". Now I make a dump from the production server with the following command:
expdp system/password#sire full=Y
directory=pump_dir dumpfile=sire_dump.dmp logfile=sire.log
The I come to the new server, and I execute impdp:
impdp system/password#sire full=Y
directory=pump_directorio dumpfile=sire_dump.dmp logfile=sire_imp.log
It starts to do the import but then I receive errors such as:
"the user vberrios does not exist". And also error beause it cannot
found some schemas and tablespaces.
My question is: It is not supposed that impdp full=Y must import all users and schemas? I have read that I have to create the users in the destination server but I have about 300 users in the database. How can I do a full import in a empty server. I just want to import the full database and user and all objects.
The documentation states, that impdp will create uses, when the dump file contains the create user statements:
If the schema you are remapping to does not already exist, the import
operation creates it, provided the dump file set contains the
necessary CREATE USER metadata and you are importing with enough
privileges.
So either your dump file is incomplete (for example due to missing privileges) or you are lacking privileges on the target database.
So please check your privileges on both, the source database and the target database. Please update your question with then according information. For the export to include the schema definitions, you must have the DATAPUMP_EXP_FULL_DATABASE privilege.

How to create a dump?

I'm one of the junior DBA working in IT company.In my company there are so many schemas is there.Now my question is How to create a dump file(some times i'm working at home.That time how to use that dump file ).Please suggest me
NOTE:I am using Oracle SQL Developer.
Expdp helps in exporting the database and impdp helps in importing the database. you can directly export one schema to another (in different database also) by using network link concept.
If network link concept is used then the creation of separate expdp file is not required.
For example If you have to export a schema called schema1 with password pwd1 from source database to target database then
first you need admin privileges of your target and source schema.
You can create a network link between source and target schema
CREATE PUBLIC DATABASE LINK example_link
CONNECT TO schema1 IDENTIFIED BY pwd1
USING 'server_name:port/service_name';--(put source database server_name,port and service name)
then create a directory in your target server :-
CREATE OR REPLACE DIRECTORY exp_dir AS 'F:/location';
grant read,write on directory exp_dir to schema1;
After this login to your target server and from command line use the below command:
impdp dba_username/dba_pwd network_link=example_link directory=exp_dir remap_tablespace=source_tbs:target_tbs remap_schema=schema1:schema1 parallel=2
You should use the Oracle Data Pump tool. The tool allows you to export your data into a .dmp file and import it into any database. Here is a video showing how to use the data pump tool in SQLDeveloper. I think this is a relatively new feature in SQLDeveloper, so make sure you have the appropriate versions..
Video Tutorial HERE
From the command line, you can use data pump with the expdp and impdp commands like so..
Set your oracle environment by running the below command and providing your oracle SID
. oraenv
Then you can run your export command..
expdp directory=/bu1/dpdump/ dumpfile=myexport.dmp logfile=mylog.log schemas=users,products,sales
The parameters are as follows..
directory - the directory where to create the dumpfile and log
dumpfile - name of the dump file (should end in .dmp)
logfile - name of the log file (should end in .log)
schemas - comma seperated list of the schemas you want to export
NOTE: you need dba privileges to use datapump. It will prompt you for the credentials
Data Pump Documentation is here
Exporting of ORACLE database objects is controlled by parameters. To get familiar with EXPORT parameters type:
exp help=y
You will get a short description and the default settings will be shown.
The EXPORT utility may be used in three ways:
Interactive dialogue
Controlled through bypassed parameters
Parameterfile controlled
Example to the 2nd option:
exp scott/tiger file=empdept.expdat tables=(EMP,DEPT) log=empdept.log
Take a look at these links for further readings:
Original Export and Import
The ORACLE Import/Export Utilities

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

Resources