How to create a dump with Oracle PL/SQL Developer? - oracle

I need to take dump of a user (including tables, procedures ,etc.) as FILENAME.dmp.
If I create a new user and import that FILENAME.dmp, then everything should be created.
How can I create this dump file?
Don't tel me to use the Run > EXP or Run > IMP functions because, due to some problem, that feature is not working for me.

EXP (export) and IMP (import) are the two tools you need. It's is better to try to run these on the command line and on the same machine.
It can be run from remote, you just need to setup you TNSNAMES.ORA correctly and install all the developer tools with the same version as the database. Without knowing the error message you are experiencing then I can't help you to get exp/imp to work.
The command to export a single user:
exp userid=dba/dbapassword OWNER=username DIRECT=Y FILE=filename.dmp
This will create the export dump file.
To import the dump file into a different user schema, first create the newuser in SQLPLUS:
SQL> create user newuser identified by 'password' quota unlimited users;
Then import the data:
imp userid=dba/dbapassword FILE=filename.dmp FROMUSER=username TOUSER=newusername
If there is a lot of data then investigate increasing the BUFFERS or look into expdp/impdp
Most common errors for exp and imp are setup. Check your PATH includes $ORACLE_HOME/bin, check $ORACLE_HOME is set correctly and check $ORACLE_SID is set

Just to keep this up to date:
The current version of SQLDeveloper has an export tool (Tools > Database Export) that will allow you to dump a schema to a file, with filters for object types, object names, table data etc.
It's a fair amount easier to set-up and use than exp and imp if you're used to working in a GUI environment, but not as versatile if you need to use it for scripting anything.

Just as an update this can be done by using Toad 9 also.Goto Database>Export>Data Pump Export wizard.At the desitination directory window if you dont find any directory in the dropdown,then you probably have to create a directory object.
CREATE OR REPLACE DIRECTORY data_pmp_dir_test AS '/u01/app/oracle/oradata/pmp_dir_test';
See this for an example.

There are some easy steps to make Dump file of your Tables,Users and Procedures:
Goto sqlplus or any sql*plus
connect by your username or password
Now type host it looks like SQL>host.
Now type "exp" means export.
It ask u for username and password give the username and password of that user of which you want to make a dump file.
Now press Enter.
Now option blinks for Export file: EXPDAT.DMP>_ (Give a path and file name to where you want to make a dump file e.g e:\FILENAME.dmp) and the press enter
Select the option "Entire Database" or "Tables" or "Users" then press Enter
Again press Enter 2 more times table data and compress extent
Enter the name of table like i want to make dmp file of table student existing so type student and press Enter
Enter to quit now your file at your given path is dump file now import that dmp file to get all the table data.

Export (or datapump if you have 10g/11g) is the way to do it. Why not ask how to fix your problems with that rather than trying to find another way to do it?

Related

Open dbf file from oracle database

My instructor gave me a username and password and .dbf file and tell me to open it and try to retrieve with sqlplus and oracle database
I tried to open the dbf file from excel mysql and ms server but it i gave me an error
Speaking as a DBA: As Littlefoot stated, you can't just read a data file from an Oracle DB. At best they are proprietary binary file formats, assuming it isn't encrypted on top of that. Nor can you take a data file from one database instance and just plug it in to another database instance. You also can't import it to mySQL or any other database engine: as a stand-alone data file it can only be properly read by its original database installation (i.e. the specific database instance that created it).
Oracle has specific tools available to copy data and/or files from one database to another, but those would generally use the RMAN backup manager (used to make physical backups) or (more likely in your case) the Datapump "Transportable Tablespace" feature.
To restore it from an RMAN backup you would need a complete full backup of the entire source database instance: RMAN backup sets including all data files, redo logs (and perhaps archived logs), control files, parameter files, encryption keys,, and possibly more.
To restore a transportable tablespace dump you would need your own running Oracle database instance, the correct parameters to run the impdp import utility, and the assistance/cooperation of the DBA.
You need to confirm if the file you were given is such an export dump (though the .dbf file extension would suggest not), and how you are expected to access the data. You won't be able to just "open the file".
.DBF extension probably represents datafile; I don't think you can read it with any tool (at least, I don't know of any).
You should find an Oracle DBA who might try to help; in order to restore a database (which is contained in that file), they might need control file(s), redo log files and ... can't name what other files (I'm not a DBA).
Then, if everything goes OK, database might be started up so that you'd be able to connect to it using credentials you were given.

How to export/import full OracleDB data dump?

I am new to Oracledb. please help me to export whole data Dump and import same to another db to create another copy of database.
You need an administrative account (for example SYSTEM). Assuming you have this, the steps are:
create a directory object inside the database to map to a physical directory on both source and target
export the source database
import into the target database
For example
SQL> create directory X as '/u01/big_directory';
expdp system/mypassword#source full=Y directory=X dumpfile=full.dmp logfile=fullexp.log
impdp system/mypassword#target full=Y directory=X dumpfile=full.dmp logfile=fullimp.log
Also, check the "Database Utilities" guide in the standard Oracle documentation set for your release at docs.oracle.com

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

Data migration from Oracle 10g to Postgres db

I want to migrate the data from Oracle 10g database to Postgres db.
Oracle SQL developer has data migration option but it seems its only for migrating non oracle db to oracle.
Please let me know other options.
There's a dedicated tool for that written in Perl: Ora2Pg.
Most databases provide tools for importing from other databases but not exporting to other databases.
I have tried using ORA2PG before but it was too complicated so I found my own way to migrate from sql developer to postgres.
Here's a step by step, let me know if you have any questions.
HOW TO MIGRATE DATA FROM THE ORACLE DATABASE TO THE POSTGRES DATABASE!
Tools to download before migration: SQL Developer, WINSCP
SQL Developer
Step 1: Login into the Oracle server using SQL Developer
Step 2: Right click on the schema name > Export > Change for the format to CSV and the encoding to UTF-8. (Make sure Export DDL is unchecked) (Make sure the filename is finished with .csv )
Step 3: Click next > next > Finish (Wait till the exporting is done)
ONCE THE FILE FROM SQL DEVELOPER IS EXPORTED
Right click on the csv file, click on open with and open it with Notepad.
Click File > Save as > Change encoding to UTF-8 and save it.
Open WINSCP
STEP 1: Before logging in into your server, click on edit > Advanced > Turn ON ‘UTF-8 encoding for filenames’.
STEP 2: Login into your server
STEP 3: Click on Settings > Internal Editors > Change the Default encoding to UTF-8 > Click Ok
STEP 4: Create a new directory anywhere on your server and drag your file to that directory into WINSCP
Now the file should be on your server with the UTF-8 encoding.
Open putty
Before logging in into your server with Putty, click on Translation and change the Received data assumed to be in which character set to UTF-8 then click on DATA and change the Terminal-type string to Putty then login into your server.
Once you logged in into your server with Putty, Run the command:
Locale charmap
This command will show you the default encoding of the server.
Run that command after:
grep -Rw '/home/pgadmin/data1/1234.csv' -e 'fre'
data1 = Directory created on the server
1234.csv = Csv file inside the data1 Directory
This command will show you if the French word in your document are still lost or not.
The '/home/pgadmin/data1/1234.csv' in that command is where your file is located on your server and ‘1234.csv’ is the name of the CSV file.
If everything is good after running that command, now we’re able to put it on the Postgres database.
After entering the postgres database with the command “psql”
Step 1: Make sure you have created your own database, schema and table (if you don’t know how, Scroll down to the end of the document).
Step 2: After creating your own database, schema and table, we can run the copy command.
\Copy joe.data01 FROM ‘home/pgadmin/data1/1234.csv’ DELIMITER ‘,’ CSV HEADER encoding ‘UTF-8’ ;
If the file already has column names on the csv file, add “HEADER” in the command.
joe.data01= Name of table created
home/pgadmin/data1/1234.csv = Location of the file on the server
To view if the schema was copied, simply run the command select * from joe.data01;
To view if French words are not lost, run the command select * from joe.data01 where isa = ‘fre’ ;
How to create a Database on Postgres: CREATE DATABASE name_of_database ;
How to create a Schema on Postgres: CREATE SCHEMA name_of_schema;
How to create a Table on Postgres: create table joe.data01 (ccca CHAR(50) NOT NULL, isa CHAR(70) NOT NULL, co CHAR(150) NOT NULL) ;
We ended up migrating a fairly large database (~100 schema, with >1000 tables) from Oracle to Postgres using the approach outlined at: https://github.com/MIT-LCP/oracle-to-postgres.
You can install the package with pip install oracle2postgres. More information is at: https://pypi.org/project/oracle2postgres/
A Jupyter Notebook demonstrating the approach is at: https://github.com/MIT-LCP/oracle2postgres/blob/master/migration.ipynb.
Our general approach was to mirror the source database; convert data types where necessary; create the target database; copy across the data in chunks. It's a slightly hacky solution, but it worked well for us.
# import the package
import oracle2postgres
# create the logfile
oracle2postgres.create_logfile()
# get source database settings
source_config = oracle2postgres.get_source_config()
# get target database settings
target_config = oracle2postgres.get_target_config()
# get settings for migration
migration_config = oracle2postgres.get_migration_config()
# check the schema exist on the source database
source_engine = oracle2postgres.connect_to_source(source_config)
oracle2postgres.check_schema_exist(source_engine,source_config['schema_list'])
# check for null characters in strings in the source database
# if found, they can be removed as explained in the documentation
oracle2postgres.check_for_nulls(source_engine,source_config['schema_list'])
# create a new database on the target database
target_engine = oracle2postgres.connect_to_target(target_config)
oracle2postgres.create_database(target_config['database'],target_engine)
# create schema on the target database
target_engine = oracle2postgres.connect_to_target(target_config,target_config['database'])
oracle2postgres.create_target_schema(source_config['schema_list'],source_engine,target_engine)
# run the migration
oracle2postgres.migrate(source_config,target_config,migration_config)
If you hit problems when reusing the code, feel free to raise an issue if so and we'll do our best to help.
expand the tables section,
then select tables you want to export
right click, select export,
then select format and export (preferably insert statements or csv)

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