BLOCKING SESSION

BLOCKING SESSION
==================
set pages 1000 lines 1000
col owner for a20
col object_name for a34
col osuser for a15
col machine for a25
col object_type for a10
col inst_id for a5
select c.owner,c.object_name,c.object_type,b.sid,b.serial#, b.status, b.osuser, b.machine,b.inst_id
from gv$locked_object a ,gv$session b,dba_objects c
where b.sid = a.session_id and a.object_id = c.object_id;select s.blocking_session,s.sid,s.serial#,s.seconds_in_wait from gv$session s
where blocking_session is not null;
select SID,SESS_SERIAL#,BLOCKER_SID,BLOCKER_SESS_SERIAL#,BLOCKER_INSTANCE_ID from gV$SESSION_BLOCKERS;

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

KILL THE BLOCKING SESSION

KILL THE BLOCKING SESSION
===========================set head off;
select ‘alter system kill session ”’||sid||’,’||serial#||”’ immediate;’
from gv$session where sid=’&Blocking_session_SID’;

set heading on;

set head off;
select ‘alter system kill session ”’||sid||’,’||serial#||’,@’||inst_id||”’ immediate;’
from gv$session where sid=’&SID_TO_BE_KILLED’;

set heading on;
set head off;
select ‘alter system kill session ”’||sid||’,’||serial#||’,@’||inst_id||”’ immediate;’
from gv$session where status=’INACTIVE’ and last_call_et/60 > 60;
set heading on;

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

LOCKED OBJECTS

 

LOCKED OBJECTS

set pages 1000 lines 1000
col owner for a18
col object_name for a30
col osuser for a15
col machine for a25
col object_type for a10
col status for a10
select c.owner,c.object_name,c.object_type,b.sid,b.serial#, b.status,b.osuser,b.machine
from gv$locked_object a ,gv$session b,dba_objects c
where b.sid = a.session_id and a.object_id = c.object_id;

 

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

SHOW BLOCKERS

SHOW BLOCKERS
================
set lines 132
set pages 66
column “SER”          format 99999
column “Table”        format A10
column “SPID”         format A5
column “CPID”         format A5
column “OS User”      format A7
column “Table”        format A10
column “SQL Text”     format A40
column “Mode”         format A20
column “Node”      format A10
column “Terminal”     format A8
spool /tmp/locks.lst
select
  s.sid “SID”,
  s.serial# “SER”,
  o.object_name “Table”,
  s.osuser “OS User”,
  s.machine “Node”,
  s.terminal “Terminal”,
  –p.spid “SPID”,
  –s.process “CPID”,
  decode (s.lockwait, null, ‘Have Lock(s)’, ‘Waiting for <‘ || b.sid || ‘>’) “Mode”,
  substr (c.sql_text, 1, 150) “SQL Text”
from v$lock l,
  v$lock d,
  v$session s,
  v$session b,
  v$process p,
  v$transaction t,
  sys.dba_objects o,
  v$open_cursor c
where l.sid = s.sid
  and o.object_id (+) = l.id1
  and c.hash_value (+) = s.sql_hash_value
  and c.address (+) = s.sql_address
  and s.paddr = p.addr
  and d.kaddr (+) = s.lockwait
  and d.id2 = t.xidsqn (+)
  and b.taddr (+) = t.addr
  and l.type = ‘TM’
group by
  o.object_name,
  s.osuser,
  s.machine,
  s.terminal,
  p.spid,
  s.process,
  s.sid,
  s.serial#,
  decode (s.lockwait, null, ‘Have Lock(s)’, ‘Waiting for <‘ || b.sid || ‘>’),
  substr (c.sql_text, 1, 150)
order by
  decode (s.lockwait, null, ‘Have Lock(s)’, ‘Waiting for <‘ || b.sid || ‘>’) desc,
  o.object_name asc,
  s.sid asc;
spool off;

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

Oracle Materialized View

Oracle Materialized View

A materialized view in Oracle is a database object that contains the results of a 
query.They are local copies of data located remotely, or are used to create summary
tables based on aggregations of a table’s data.
A materialized view can query tables, views, and other materialized views. A materialized view, or snapshot as they were previously known, is a table segment
whose contents are periodically refreshed based on a query, either against a local
or remote table.

Syntax

CREATE MATERIALIZED VIEW view-name BUILD [IMMEDIATE | DEFERRED]
REFRESH [FAST | COMPLETE | FORCE ]
ON [COMMIT | DEMAND ][[ENABLE | DISABLE] QUERY REWRITE] AS SELECT …;

Methods

BUILD

IMMEDIATE : The materialized view is populated immediately.This option is default one.
DEFERRED : The materialized view is populated on the first requested refresh.

Refresh Types

  • FAST: A fast refresh is attempted only there is a change in the base table. If materialized view logs are not present against the source tables in advance, the creation fails. To maintain the history of change in the base table, it is known as materialized view log.It is named as MLOG$_<base_table>. Materialized view log will be located in the source database in the same schema as the master table. Refresh fast will perform refresh according to the changes that occurred in the master table.
  • COMPLETE: The table segment supporting the materialized view is truncated and repopulated completely using the associated query.
  • FORCE: A fast refresh is attempted. If one is not possible a complete refresh is performed.
ON COMMIT : The refresh is triggered by a committed data change in one of the 
dependent tables. ON DEMAND : The refresh is initiated by a manual request or a scheduled task.
GRANT CREATE MATERIALIZED VIEW TO INDIA;
Grant succeeded.

GRANT CREATE DATABASE LINK TO INDIA;
Grant succeeded.

Creating Database link to point remote database 

SQL> CREATE DATABASE LINK PROD_LINK CONNECT TO ph IDENTIFIED BY ph USING 'orcl';

Database link created.

COMPLETE REFRESH

Creating Materialized View

SQL> CREATE MATERIALIZED VIEW dept_mv BUILD IMMEDIATE REFRESH COMPLETE AS 
SELECT * FROM ph.emp@PROD_LINK; Materialized view created.
SQL> select * from emp;

        NO NAME                     SALARY
---------- -------------------- ----------
         1 apple                     20000
         2 orange                    23000
         3 mango                     32000

Table Data present in Remote database

SQL> insert into emp values (6,'ice',30000);

1 row created.

SQL> commit;

Commit complete.

SQL> select rowid,no,name,salary from dept_mv;

ROWID                      NO NAME                     SALARY
------------------ ---------- -------------------- ----------
AAAR36AABAAAbURAAA          1 apple                     20000
AAAR36AABAAAbURAAB          2 orange                    23000
AAAR36AABAAAbURAAC          3 mango                     32000

Manually using complete refresh using the DBMS_VIEW package

SQL>  execute DBMS_MVIEW.REFRESH( LIST => 'dept_mv', METHOD => 'C' );

PL/SQL procedure successfully completed.

SQL> select rowid,no,name,salary from dept_mv;

ROWID                      NO NAME                     SALARY
------------------ ---------- -------------------- ----------
AAAR36AABAAAbURAAD          1 apple                     20000
AAAR36AABAAAbURAAE          2 orange                    23000
AAAR36AABAAAbURAAF          3 mango                     32000
AAAR36AABAAAbURAAG          6 ice                       30000

DEFERRED

Initially drop the existing materialized view

SQL> drop MATERIALIZED VIEW dept_mv;

Materialized view dropped.

Materialized view creation using DEFERRED option

SQL> CREATE MATERIALIZED VIEW dept_mv BUILD DEFERRED REFRESH COMPLETE AS 
SELECT * FROM ph.emp@PROD_LINK; Materialized view created. SQL> execute DBMS_MVIEW.REFRESH( LIST => 'dept_mv', METHOD => 'C' ); PL/SQL procedure successfully completed.
QL> select rowid,no,name,salary from dept_mv;

ROWID                      NO NAME                     SALARY
------------------ ---------- -------------------- ----------
AAAR39AABAAAbURAAA          1 apple                     20000
AAAR39AABAAAbURAAB          2 orange                    23000
AAAR39AABAAAbURAAC          3 mango                     32000
AAAR39AABAAAbURAAD          6 ice                       30000

 

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

Linux File Compress commands

File Compress commands 

Linux we have two types of compress commands

  1. GZIP
  2. GUNZIP

To reduce the file size by using compress commands

gzip – This command used to compress the file size

[oracle@oracletest scripts]$ gzip ramkumar.txt
[oracle@oracletest scripts]$ ls -l
total 24
-rwxrwxrwx. 1 oracle oracle 72 Oct 21 01:49 ramkumar.txt.gz
-rwxrwxr-x. 1 oracle oracle 1291 Oct 20 23:47 rman_bkp.sh
-rw-rw-r--. 1 oracle oracle 6979 Oct 20 23:48 rman.log
-rwxr--r--. 1 oracle oinstall 515 Sep 9 14:45 setEnv.sh
-rwxr--r--. 1 oracle oinstall 134 Sep 7 10:54 stop_all.sh

Gunzip – This command is user to unzip the original file size

[oracle@oracletest scripts]$ gunzip ramkumar.txt.gz
[oracle@oracletest scripts]$ ls -l
total 24
-rwxrwxrwx. 1 oracle oracle 42 Oct 21 01:49 ramkumar.txt
-rwxrwxr-x. 1 oracle oracle 1291 Oct 20 23:47 rman_bkp.sh
-rw-rw-r--. 1 oracle oracle 6979 Oct 20 23:48 rman.log
-rwxr--r--. 1 oracle oinstall 515 Sep 9 14:45 setEnv.sh
-rwxr--r--. 1 oracle oinstall 134 Sep 7 10:54 stop_all.sh
[oracle@oracletest scripts]$

 

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

Linux Link Commands

Linux Link Commands

Creating links is a kind of shortcut to access a file. Links allow more than one file name to refer to the same file.

There are two types of links :

  1. Hard Link
  2. Soft Link or Symbolic links

Hard Link

A hard link is one most power full links in the Linux system when we create a hard link to the file and then delete the file, we can still access the file using the hard link.

syntax : ln file_name link_name
Eg: ln ramkumar.txt ram

[oracle@oracletest scripts]$ ls -l
total 24
-rwxrwxrwx. 1 oracle oracle 42 Oct 21 01:49 ramkumar.txt
-rwxrwxr-x. 1 oracle oracle 1291 Oct 20 23:47 rman_bkp.sh
-rw-rw-r--. 1 oracle oracle 6979 Oct 20 23:48 rman.log
-rwxr--r--. 1 oracle oinstall 515 Sep 9 14:45 setEnv.sh
-rwxr--r--. 1 oracle oinstall 134 Sep 7 10:54 stop_all.sh
[oracle@oracletest scripts]$ ln ramkumar.txt ram
[oracle@oracletest scripts]$ ls -l
total 28
-rwxrwxrwx. 2 oracle oracle 42 Oct 21 01:49 ram
-rwxrwxrwx. 2 oracle oracle 42 Oct 21 01:49 ramkumar.txt
-rwxrwxr-x. 1 oracle oracle 1291 Oct 20 23:47 rman_bkp.sh
-rw-rw-r--. 1 oracle oracle 6979 Oct 20 23:48 rman.log
-rwxr--r--. 1 oracle oinstall 515 Sep 9 14:45 setEnv.sh
-rwxr--r--. 1 oracle oinstall 134 Sep 7 10:54 stop_all.sh
[oracle@oracletest scripts]$ cat ram
HI 
Hello
welcome to linux basic commands
[oracle@oracletest scripts]$ rm -rf ramkumar.txt
[oracle@oracletest scripts]$ ls -l
total 24
-rwxrwxrwx. 1 oracle oracle 42 Oct 21 01:49 ram
-rwxrwxr-x. 1 oracle oracle 1291 Oct 20 23:47 rman_bkp.sh
-rw-rw-r--. 1 oracle oracle 6979 Oct 20 23:48 rman.log
-rwxr--r--. 1 oracle oinstall 515 Sep 9 14:45 setEnv.sh
-rwxr--r--. 1 oracle oinstall 134 Sep 7 10:54 stop_all.sh
[oracle@oracletest scripts]$ cat ram
HI 
Hello
welcome to linux basic commands


 

Soft Link or Symbolic links

Soft link is another variety type of Linux link, But if we create a soft link of the file and then delete the file, we can’t access the file through the soft link, and the soft link becomes dangling

Syntax: ln -s file_name link_name

Eg: ln -s ramkumar.txt ram

Eg: ls -s sample.txt kar

[oracle@oracletest scripts]$ ln -s sample.txt kar
[oracle@oracletest scripts]$ ls -l
total 28
lrwxrwxrwx. 1 oracle oracle 9 Oct 21 23:12 ram -> sample.txt
-rw-rw-r--. 1 oracle oracle 49 Oct 21 23:12 ramkumar.txt
-rwxrwxrwx. 1 oracle oracle 42 Oct 21 01:49 ram
-rwxrwxr-x. 1 oracle oracle 1291 Oct 20 23:47 rman_bkp.sh
-rw-rw-r--. 1 oracle oracle 6979 Oct 20 23:48 rman.log
-rwxr--r--. 1 oracle oinstall 515 Sep 9 14:45 setEnv.sh
-rwxr--r--. 1 oracle oinstall 134 Sep 7 10:54 stop_all.sh
[oracle@oracletest scripts]$ cat ram
Good morning
How are you all
Take care
Bye Bye !
[oracle@oracletest scripts]$ rm -rf sample.txt
[oracle@oracletest scripts]$ ls -l
total 24
lrwxrwxrwx. 1 oracle oracle 9 Oct 21 23:12 ram -> sample.txt
-rwxrwxrwx. 1 oracle oracle 42 Oct 21 01:49 ram
-rwxrwxr-x. 1 oracle oracle 1291 Oct 20 23:47 rman_bkp.sh
-rw-rw-r--. 1 oracle oracle 6979 Oct 20 23:48 rman.log
-rwxr--r--. 1 oracle oinstall 515 Sep 9 14:45 setEnv.sh
-rwxr--r--. 1 oracle oinstall 134 Sep 7 10:54 stop_all.sh
[oracle@oracletest scripts]$ cat ram
cat: ram: No such file or directory

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

Linux search commands

Linux search commands

In Linux, we have four various types of search commands

  • Grep

Grep is an acronym that stands for Global Regular Expression Print.

Grep is a Linux command used to search for a string of characters in a specified file.

To Search a File:

Syntax: Grep match_string file_name

Eg: grep database sample1

To Search Multiple Files: 

To search multiple files with the grep command, insert the filenames you want to search, separated with a space character.

Syntax: grep match_string file_name file_name

Eg: grep database sample1 sample2 sample3
  • AWK

AWK this command  is used for pattern search and processing, scanning files line by line then performing specified actions on matching lines

Syntax: awk ‘{search options from to}’ file_name

Eg: $ awk '{print $2 "\t" $3}' file.txt
  • Locate

locate command and find command is used to search a file by name. But, the difference between both commands is that locating command is a background process and searches the file in the database whereas, find command searches in the file system. The locate command is much faster than the find command.

We have some options in locating search commands by locate -h (help cmd)
Search for entries in a locate database.

-A, --all only print entries that match all patterns
-b, --basename match only the base name of path names
-c, --count only print number of found entries
-d, --database DBPATH use DBPATH instead of default database (which is
/var/lib/mlocate/mlocate.db)
-e, --existing only print entries for currently existing files
-L, --follow follow trailing symbolic links when checking file
existence (default)
-h, --help print this help
-i, --ignore-case ignore case distinctions when matching patterns
-l, --limit, -n LIMIT limit output (or counting) to LIMIT entries
-m, --mmap ignored, for backward compatibility
-P, --nofollow, -H don't follow trailing symbolic links when checking file
existence
-0, --null separate entries with NUL on output
-S, --statistics don't search for entries, print statistics about each
used database
-q, --quiet report no error messages about reading databases
-r, --regexp REGEXP search for basic regexp REGEXP instead of patterns
--regex patterns are extended regexps
-s, --stdio ignored, for backward compatibility
-V, --version print version information
-w, --wholename match whole path name (default)
Syntax: locate {Options…..} (filename)

 Eg:  locate ramkumar.txt

[oracle@oracletest pfile]$ locate ramkumar.txt
/home/oracle/scripts/ramkumar.txt

  • Find

find command is one of the most powerful tools in Linux, It supports searching by file, folder, name, creation date, modification date, owner, and permissions.

By using the ‘-exec’

Syntax: find [where to start searching from]
[expression determines what to find] [-options] [what to find]

Eg: find ramkumar

Options :

-exec CMD: The file being searched which meets the above criteria and returns 0 
for as its exit status for successful command execution.

-ok CMD : It works same as -exec except the user is prompted first.

-inum N : Search for files with inode number ‘N’.

-links N : Search for files with ‘N’ links.

-name demo : Search for files that are specified by ‘demo’.

-newer file : Search for files that were modified/created after ‘file’.

-perm octal : Search for the file if permission is ‘octal’.

-print : Display the path name of the files found by using the rest of the criteria.

-empty : Search for empty files and directories.

-size +N/-N : Search for files of ‘N’ blocks; ‘N’ followed by ‘c’can be used to 
measure size in characters; ‘+N’ means size > ‘N’ blocks and ‘-N’ means 
size < 'N' blocks.

-user name : Search for files owned by user name or ID ‘name’.

\(expr \) : True if ‘expr’ is true; used for grouping criteria combined with OR or AND.

! expr : True if ‘expr’ is false.

 

 

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

Linux File Commands

Linux File Commands

File creating commands

Touch: This touch command is used to update the timestamps on existing files and as creating new files and empty files.

 

 

Vi: virtual editor vi filename.txt commands used to create a virtual editor

By pressing keys on the keyboard to perform an action in vi


Insert – a,I,o,u

  • :w! – Save the file but keep it open
  • :q! – Quit without saving:
  • :wq! – Save the file and quit

Cat: This cat command is mainly used to read files, But it can also be used to create new files.

 

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8

Linux Basic Commands

Linux Basic Commands

BASIC COMMANDS

Hostname: Hostname command in Linux is used to find the DNS (Domain Name System)

Hostname a: This command is used to get the Domain Name of the host system

Hostname -d: This command is used to get the local domain

Hostname -i: This command is used to get the IP(network) addresses

Hostname –v: This command gives version number as output

Uname command: This command is used to display basic information about the operating system and hardware.

Uname -s:  This command is used to get the kernel name

Uname -r: This command is used to get kernel release

Uname -v: This command is used to get the kernel version

Uname -n: This command is used to get node name

Uname-a: This command is used to get shows all parameters

Uname -m: This command is used to get the hardware name

 

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8