0% found this document useful (0 votes)
2 views

create dump of user by using cmd mode

The document contains various SQL commands and procedures for managing users, schemas, and data in an Oracle database. It includes instructions for creating users, granting permissions, importing and exporting schemas, and checking table sizes and constraints. Additionally, it provides commands for changing passwords, dropping users, and managing directories and tablespaces.

Uploaded by

enamul whab
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

create dump of user by using cmd mode

The document contains various SQL commands and procedures for managing users, schemas, and data in an Oracle database. It includes instructions for creating users, granting permissions, importing and exporting schemas, and checking table sizes and constraints. Additionally, it provides commands for changing passwords, dropping users, and managing directories and tablespaces.

Uploaded by

enamul whab
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

may 22

joisto 7
thrusday

1. MPGM -- Program Master


2. EURPGMAR --User/Role wise Rights Allocation for Programs

***********************************************************************************
********************************
Rename User
***********************************************************************************
********************************
User ID : BOZLU
Pass: sonali1234

jdbc:oracle:thin:@localhost:1521:orcl

select to_char(to_date('&date', 'DD-MM-YYYY'), 'Day') day from dual; --- this query
will be find your weekday from given date
select * from dba_object_size where name = 'procedure_name'

***********************************************************************************
********************************
user_constraints error Check
***********************************************************************************
********************************

select * from user_constraints c where c.owner='SBBDPROD_14AUG' and


c.constraint_name='PK_CORPCLINEACT';

***********************************************************************************
********************************
Create User With max Grants
***********************************************************************************
********************************

CREATE USER username IDENTIFIED BY password DEFAULT TABLESPACE TBFES;


GRANT DBA TO username;
GRANT CREATE SESSION,CREATE TABLE,CREATE SEQUENCE,CREATE VIEW TO username;
GRANT EXECUTE ON DBMS_SQLHASH TO username;
GRANT EXECUTE ON DBMS_LOCK TO username;
GRANT DEBUG CONNECT SESSION TO username;
GRANT DEBUG ANY PROCEDURE TO username;
GRANT DBA TO username;
GRANT CREATE SESSION,CREATE TABLE,CREATE SEQUENCE,create type,CREATE VIEW TO
username;
GRANT EXECUTE ON DBMS_SQLHASH TO username;
GRANT EXECUTE ON DBMS_LOCK TO username;
GRANT DEBUG CONNECT SESSION TO username;
GRANT DEBUG ANY PROCEDURE TO username;
GRANT READ,WRITE ON DIRECTORY DUMP TO username;
GRANT CREATE TYPE TO username;
GRANT READ,WRITE ON DIRECTORY DATA_DIR TO username;

-------------------------------------------------------------------
--Create User--
-------------------------------------------------------------------
CREATE USER SBBDPROD_06SEP IDENTIFIED BY SBBDPROD_06SEP
DEFAULT TABLESPACE TBFES;
GRANT DBA TO SBBDPROD_06SEP;
GRANT CREATE SESSION,CREATE TABLE,CREATE SEQUENCE,
CREATE VIEW TO SBBDPROD_06SEP;
GRANT EXECUTE ON DBMS_SQLHASH TO SBBDPROD_06SEP;
GRANT EXECUTE ON DBMS_LOCK TO SBBDPROD_06SEP;
GRANT DEBUG CONNECT SESSION TO SBBDPROD_06SEP;
GRANT DEBUG ANY PROCEDURE TO SBBDPROD_06SEP;
GRANT READ,WRITE ON DIRECTORY DATA_PUMP_DIR TO SBBDPROD_06SEP;

-------------------------------------------------------------------
--Import Dump--
-------------------------------------------------------------------

host(impdp SBBDPROD/s directory=DUMP dumpfile=RBLPROD_16JAN14_BEOD.dmp


logfile=IMP_RBLPROD_16JAN14_BEOD_TO_UAT.log remap_schema=RBLPROD_27DEC:RBLUAT_27DEC
transform=oid:n)

-------------------------------------------------------------------
remote DB ACCESS
-------------------------------------------------------------------
sqlplus username/password@hostA:1521 /XE

***********************************************************************************
********************************
Import Schema
***********************************************************************************
********************************

impdp SBBDPROD_06SEP/SBBDPROD_06SEP directory=data_dir dumpfile=EOD_O6SEPT.DMP


logfile=EOD_O6SEPT.log remap_schema=SBBDPROD_01SEPT_LIVE:SBBDPROD_06SEP
transform=oid:n
--or--
impdp SBBDPROD_06SEP/[email protected]:1521/orcl directory=data_dir
dumpfile=EOD_O6SEPT.DMP logfile=EOD_O6SEPT.log
remap_schema=SBBDPROD_01SEPT_LIVE:SBBDPROD_06SEP transform=oid:n
--or--
impdp username/password@orcl directory=data_dir dumpfile=EXPDP_sbbdprod.dmp
logfile=rajesh.log parallel=10

--after imported dump we should be check the total amount of invalid objects. if
it's greater then 24 then this is a bad dump

imp STLBAS_30/admin file= D:\dump_dir\BCBL_[Sun_23_30]_P.dmp fromuser=STLBAS


touser=STLBAS_30 log=abcclone.log
IMP SBBDSEED/SBBDSEED FILE=/u01/app/oracle/product/11.2.0/db_1/rdbms/log/Backup.DMP
log=/u01/app/oracle/product/11.2.0/db_1/rdbms/log/Backup.LOG
FROMUSER=SBBDPROD_19SEPT TOUSER=SBBDSEED IGNORE=Y
imp SBBDSEED/SBBDSEED FILE=/u01/app/oracle/product/11.2.0/db_1/rdbms/log/Backup.DMP
FROMUSER=SBBDPROD_19SEPT TOUSER=SBBDSEED IGNORE=Y

***********************************************************************************
********************************
Change Password
***********************************************************************************
********************************
alter user user_name identified by new_password;

***********************************************************************************
********************************
Export Schema
***********************************************************************************
********************************

expdp SBBDPROD/sonali1234 schemas=SBBDPROD directory=DUMPDIR


dumpfile=EXPDP_SBBDPROD_16MAR.dmp logfile=EXPDP_SBBDPROD_16MAR.log

/u02/export/dump
-- export tables only

EXP USERID=SBBD_MIG_16MAY/SBBD_MIG_16MAY@ORCL
FILE="D:/Migration/OutputFiles/SBBD_MIG_30MAY.DMP"
LOG="D:/Migration/OutputFiles/EXP_BCBLSEED_MIG_Backup.LOG"
TABLES="ACASLL,ACASLLDTL,ACNTBAL,ACNTBBAL,ACNTCBAL,ACNTCBBAL,ACNTCONTRACT,ACNTCVDBB
AL,ACNTFRZ,ACNTLINK,ACNTMAIL,temp_sec,ACNTOTN,ACNTS,ACNTLIEN,ACNTSTATUS,ACNTVDBBAL,
ADVBAL,ADVBBAL,ADVVDBBAL,ASSETCLS,ASSETCLSHIST,BATCHCOUNTER,CBISS,CLIENTNUM,CLIENTO
TN,CLIENTOTNDTL,CLIENTS,CLIENTSBKDTL,CONNPINFO,CORPCLIENTS,DDPOISS,DDPOISSDTL,DDPOI
SSDTLANX,DDPOPAYDB,DENOMBAL,DENOMDBAL,DEPACCLIEN,depcls,DEPINTPAYMENT,DEPINTPAYMENT
DTL,GLBBAL,GLSUM2010,GLSUM2011,GLSUM2012,IACLINK,INDCLIENTS,JOINTCLIENTS,JOINTCLIEN
TSDTL,LADACNTDTL,lngsacnts,lngsacntdtl,LADACNTS,LIMITLINE,limitlinehist,LIMITSERIAL
,LLACNTOS,LLPROD,LNACAODHIST,LNACDISB,LNACDSDTL,LNACDSDTLHIST,LNACGUAR,LNACIR,LNACI
RHIST,LNACIRS,LNACIRSHIST,LNACMIS,LNACMISHIST,LNACRS,LNACRSDTL,LNACRSHDTL,LNACRSHIS
T,LNSUSPBAL,LNSUSPLED,LOANACNTOTN,LOANACNTS,MARGINREC,NOMENTRY,NOMREG,PBCOUNT,PBDCO
NTDSA,PBDCONTDSAHIST,PBDCONTRACT,PIDDOCS,PROVLED,RDINS,STOPCHQ,STOPLEAF,TDSPI,TDSPI
DTL,TRAN2010,TRANADV2010,TRANBAT2010,tranadvaddn2010,TRAN2011,TRANADV2011,TRANBAT20
11,tranadvaddn2011,TRAN2012,TRANADV2012,TRANBAT2012,tranadvaddn2012,VAULTBAL,VAULTD
BAL,TBILLSERIAL,INVSPDOCIMG,CLAMIMAGE,spdocimage,SECRCPT,SECASSIGNMENTS,SECASSIGNMT
DTL,SECASSIGNMTBAL,SECASSIGNMTDBAL,SECMORTGAGE,SECMORTEC,SECINVEST,SECVEHICLE,SECCL
IENT,SECSHARES,SECSHARESDTL,SECINSUR,SECSTKBKDB,SECSTKBKDBDTL,SECSTKBKDT,SECSTKBKDT
DTL,LNDP,LNDPHIST,LIMFACCURR,LIMITLINEAUX,LOANACHIST,LOANACHISTDTL,LOANACDTL,LIMITL
INECTREQ,LNSUBVENRECV,LNACSUBSIDY,LNACIRDTL,LNACIRHDTL,addrdtls,PBDCONTTRFOD,TDSREM
ITGOV,HOVERING,HOVERRECBRK,amlacturnover,hoverseq,ecsacmap,LADDEPLINK,LADDEPLINKHIS
T,LADDEPLINKHISTDTL,LNGOVTSEC,SECVAL,LOCKERAVL,LOCKERAVLHIST,LOCKERAM,LOCKERCHGSHIS
T,LOCKERACCHIST,LOCKERACC,LOCKERKEYHIST,LOCKERKEY,LOCKERDTLS,LOCKERRENT,LOCKERSTAT,
LOCKERSTATHIST,ACSEQGEN,DEPRCPTPRNT,LEGALNOTICE,LEGALSTAT,LEGALACTION,LNACINTCTL,LN
ACINTCTLHIST,ITFORMS,CLIENTMEM,MEMNUM,DEPCLIENTNOMMEM,NOMINALMEMNUM,LNNOMINALMEM,LN
NOMINALMEMDTL,ACNTOTN,ACNTOTNNEW,LNACCHGS,LNACCHGSQBAL,LNACCHGSQLED,VAULTDBAL,DENOM
DBAL,LNACINTARHIST,LNACINTARDTL,LNACINTARHDTL,LNACINTAR,LNTOTINTDBMIG,SMSBREG,SMSBR
EGDTL,SMSBREGSVC,ivracnts,,IBS_AC_BAL,MIG_LDR,MIG_TDS,MIG_FWD,MIG_RD,IBS_GL_BAL,IBS
_NOMENTRY,MIG_DP,MIG_PDISB,MIG_FWDCFINT,MIG_SBACCR,MIG_CLIENT_ACCESS,MIG_ACNTS_ACCE
SS,MIG_DEP_ACCESS,MIG_CLIENTSBKDTL_ACCESS,MIG_CLNT_KYCACC,MIG_JOINTCLIENTSDTL_ACCES
S,MIG_JOINTCLIENTS_ACCESS,MIG_OVERDUE_DETAILS,MIG_CP,MIG_OBC,MIG_IBC,MIG_SCH_MAST,M
IG_TL_MAST,MIG_INT_MAST,MIG_CHEQ_BK,MIG_CHEQSTOP,MIG_CUMUSUB,MIG_NPARPT,MIG_BANK,MI
G_BR_PARA,MIG_AC_MAST_NEW,MIG_D_MAST_NEW,MIG_LNRPST,TEMP_CLIENT,DEPIA,LOANIA,SBCAIA
,LOANIADTL,SBCAIABRK,ACBALASONHIST,GLSUM2013,TRAN2013,TRANADV2013,TRANBAT2013,trana
dvaddn2013,ACBALASONHIST_MAX,ACBALASONHIST_AVGBAL,NOMREGDTL,ACBALASONHIST_MAX";

***********************************************************************************
*********************************
Export Schema by cmd mode
***********************************************************************************
*********************************

C:\Users\rajesh.poddar>exp

Export: Release 11.2.0.1.0 - Production on Sun May 19 18:20:54 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Username: scott
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Produc
tion
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Enter array fetch buffer size: 4096 > 4096

Export file: EXPDAT.DMP > D:\oradump\scott.dmp

(2)U(sers), or (3)T(ables): (2)U > U

Export grants (yes/no): yes > yes

Export table data (yes/no): yes > yes

Compress extents (yes/no): yes > yes

Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user SCOTT
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user SCOTT
About to export SCOTT's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export SCOTT's tables via Conventional Path ...
. . exporting table DEPT 4 rows exported
. . exporting table EMP 14 rows exported
. . exporting table SALGRADE 5 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.
C:\Users\rajesh.poddar>

*******************************************************************
show all table list
*******************************************************************
select * from tab;
select count(*) from tab; \\ count tables with views
select count(TABLE_NAME) from user_tables; \\ count only tables
or
select * from tab where tabtype='TABLE';

***********************************************************************************
*****************
show all table with size ( biggest first )
***********************************************************************************
*****************
---ROUND(sum(bytes)/1024/1024/1024, 2) GB (Calculation for GB)

select TABLE_NAME ,round((num_rows*avg_row_len)/(1024*1024)) MB from user_tables


order by MB desc;

---- Ignore 0 rows tables


select TABLE_NAME, round((num_rows * avg_row_len) / (1024 * 1024)) MB
from user_tables
where num_rows > 0
order by MB desc;

***********************************************************************************
*****************
Count all tables rows according to Users
***********************************************************************************
*****************
select owner, table_name, num_rows
from all_tables
where owner like 'STLBAS' -- Exclude system tables.
and num_rows > 0 -- Ignore empty Tables.
order by num_rows desc -- Biggest first.
;

--loan table search


select *
from (select TABLE_NAME, num_rows
from user_tables u
where u.TABLE_NAME like 'LN%'
or u.TABLE_NAME like 'LOAN%') k
where k.num_rows > 0;

******************************************
drop/delete table
******************************************
drop table table_name;
******************************************
table backup
******************************************
create table table_name as select * from mig_clients;

******************************************
show user DBA ROLES
******************************************

select * from DBA_ROLES;


select * from session_roles;
select * from role_sys_privs;

******************************************
drop user
******************************************

SQL>DROP USER scott CASCADE;

******************************************
show all users
******************************************

SQL>select username from dba_users;


SQL>select * from all_users;

******************************************
unlock users
******************************************

SQL> sys as sysdba


SQL> alter user hr account unlock;
SQL> grant connect, resource to hr;

--After unlocking account I changed password to prash

SQL> ALTER USER hr IDENTIFIED BY hr;

*********************************************************************
Create directories
*********************************************************************

SQL> create or replace directory dir_temp as 'c:\temp';

*********************************************************************
show all directories
*********************************************************************

SQL> SELECT * FROM dba_directories;


SQL> desc dba_directories;
SQL> DROP DIRECTORY ctemp;
for help : http://psoug.org/reference/directories.html

*********************************************************************
show all tablespace name
*********************************************************************

SQL> select TABLESPACE_NAME from USER_TABLESPACES;

*********************************************************************
show hidden file from cmd mode
*********************************************************************

1. go to cmd mode then


C:\Users\rajesh.poddar>ATTRIB -H C:\Users\rajesh.poddar\Desktop\hidden.txt

*********************************************************************
how to change hosts file
*********************************************************************

host file location : C:\Windows\System32\drivers\etc\hosts

1.copy hosts file to desktop


2.modify its content
3.go to "C:\Windows\System32\drivers\etc\" location and rename existing hosts file
to hosts1
4.paste modified hosts file to this location.
5.and finally delete hosts1 file

*********************************************************************
loginctl.class file location in Panacea.ear
*********************************************************************

SBBD\Panacea.ear\Panaceaweb.war\WEB-INF\classes\panaceaFLweb\FLCtlbean\
loginctl.class

You might also like