0% found this document useful (0 votes)
6 views4 pages

Oracle Commands

The document provides a comprehensive guide on using Oracle commands for database management, including creating a new schema/user, granting rights, and exporting/importing data. It outlines the steps to create tablespaces, users, and how to manage user permissions, as well as commands for exporting and importing schemas and entire databases. Additionally, it includes useful SQL queries to check users and tables within the Oracle database.

Uploaded by

myasirm8993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Oracle Commands

The document provides a comprehensive guide on using Oracle commands for database management, including creating a new schema/user, granting rights, and exporting/importing data. It outlines the steps to create tablespaces, users, and how to manage user permissions, as well as commands for exporting and importing schemas and entire databases. Additionally, it includes useful SQL queries to check users and tables within the Oracle database.

Uploaded by

myasirm8993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Oracle Commands:

=================

1. Go to Command Prompt
2. write: sqlplus and enter
3. enter user id & password of system as: system/system123@orcl

Note:
system is oracle main user
system123 is system password (it can be vary in different installations)
@orcl is the SID or Service Name (this can be vary in different installations,
mostly it is orcl)

===================================================================================
=================
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
===================================================================================
=================

Create a new schema/user:


===========================

1. create a tablespace first:


------------------------------

CREATE TABLESPACE tbs_Prism


DATAFILE 'datafile_Prism.dbf'
SIZE 10M AUTOEXTEND ON;

Note:
tbs_Prism is the tablespace name, you can put any name for each schema or keep the
same for all, default tablespace in oracle is Users
As you create a new tablespace so you have to create a new datafile with .dbf
extension
Size is initial size of db, autoextend On means it will grow with data. if not
given, it keeps the db file size to 10 MB (as given here) and then stop saving data
when reached to its size.

-----------------------------------------------------------------------------------
--

2. create a user in this tablespace:


-------------------------------------
CREATE USER PrismERP IDENTIFIED BY password
DEFAULT TABLESPACE tbs_Prism
TEMPORARY TABLESPACE temp;

Note:
PrismERP is the user / schema name
Identified by - refer to password i.e password here: Password in oracle is case
sensitive
given tablespace that created above
with temporary tablespace for transaction purpose.
-----------------------------------------------------------------------------------
--

3. Give rights to user/schema:


-------------------------------

grant dba to PrismERP;

Note: this gives the full dba rights to user PrismERP;


you can give more specific rights (not mandatory, but given if required) as well,
given below:

grant resource, create session, create view to PrismERP;


grant create user, alter any triger to PrismERP;
grant resource to PrismERP with Admin Option;

-----------------------------------------------------------------------------------
--

4. Drop or Delete a User / Schema:


----------------------------------

drop user PrismERP cascade;

Note: this will delete the user from Oracle, memory and from oracle recycle bin too
drop user required when you have no need of schema or import a new backup / dump
file on the same user/schema.

===================================================================================
=================
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
===================================================================================
=================

Export (make a backup) file from Oracle:


====================================================

1. Create a directory at C or D - Drive with any name, like "Dump"

2. write the following commands in the above open command prompt / sqlplus:

CREATE OR REPLACE DIRECTORY dump AS 'C:\Dump';

GRANT READ, WRITE ON DIRECTORY dump TO PrismERP;

3. Open a new command prompt and enter the following command:

expdp system/system123@orcl schemas=PrismERP directory=Dump dumpfile=PrismERP.dmp


logfile=expdpPrismERP.log

Note:
expdp = export data pump command
system/system123@orcl = system user and password with service / SID name (i.e full
qualified name)
schemas=PrismERP == the schema / user want to export
directory=Dump == the directory created above
dumfile= anyname.dmp (mostly keep the same name as schema, with extension .dmp)
logfile= anyname.log (this to check the events, logs while running export command)

Import (from a dump) file to Oracle:


====================================================

To import a dump file into a user

-- if already created and have data, drop it first


--> Follow the "Create a new schema/user"

if already created but blank, start from here:

impdp PrismERP/password@orcl schemas=PrismERP directory=Dump dumpfile=PrismERP.dmp


logfile=impdpPrismERP.log

Note: in case if importing from a different schema, and into a different tablespace
use the following command:

impdp system/system123@orcl SCHEMAS=PrismERP remap_schema=PrismERP:PrismNew


remap_tablespace=users:tbs_Prism directory=dump dumpfile=PrismERP.dmp
logfile=impdpPrismNew.log

===================================================================================
=================
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
===================================================================================
=================

Other useful commands in Oracle:


================================

To check all users in oracle:

select * from dba_users;

===================================================================================
=================

To select specific user:


========================

select username from dba_users;

Note: username replace with any user name like PrismERP

===================================================================================
=================

To select / show all tables in a user/schema:


==============================================

SELECT
table_name, owner
FROM
all_tables
WHERE
owner='PrismERP'
ORDER BY
owner, table_name

------------------------------------

SELECT TABLE_NAME
FROM ALL_TABLES
WHERE OWNER='PrismERP'

------------------------------------

connect PrismERP/password;
select table_name from user_tables;

Note: this command use when connected to a schema, like PrismERP

===================================================================================
=================
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
===================================================================================
=================

To Database Exports/Imports instead of a user/schema:


=====================================================
Note: A database can contain many users/schema like PrismERP, PrismNew, abc,
xyz ....

To Export:
----------
expdp system/system123@orcl full=Y directory=Dump_DB dumpfile=orcl.dmp
logfile=expdpORCL.log

To Import:
----------
impdp system/password@db10g full=Y directory=Dump_DB dumpfile=DB10G.dmp
logfile=impdpDB10G.log

===================================================================================
=================
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
===================================================================================
=================

You might also like