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:
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:
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 fromdept_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.
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 :
Hard Link
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.
[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 Hellowelcome 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:
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)
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:
Every file and directory in your Linux system has the following 3 permissions defined for all the 3 owners discussed above.
Read: This permission give you the authority to open and read a file.
Write: The write permission on a directory gives you the authority to add, remove and rename files stored in the directory
Execute: In Windows, an executable program usually has an extension “.exe” and which you can easily run. Linux, you cannot run a program unless the execute permission is set. If the execute permission is not set, you might still be able to see/modify the program code(provided read & write permissions are set), but not run it.
Let’s see file permissions in Linux with examples:
ls – l This list command will show the file permissions
[oracle@oracletest scripts]$ ls -l
total 24
-rw-rw-r--. 1 oracle oracle 42 Oct 21 01:49 kiruba.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
So, Here we listed some files with permissions
r = read permission w = write permission x = execute permission – = no permission
permissions with chmod command
We can use the chmod command which stands for change mode. Using the command, we can set permissions (read, write, execute) on a file/directory for the owner, group.
There are 2 ways to use the command
Absolute mode
Symbolic mode
Absolute(Numeric) Mode
In this mode file permissions are not represented as characters, we can give in a three-digit octal number.
Number
Permission Type
Symbol
0
No Permission
—
1
Execute
–x
2
Write
-w-
3
Execute + Write
-wx
4
Read
r–
5
Read + Execute
r-x
6
Read +Write
rw-
7
Read + Write +Execute
rwx
Example: chmod three-digit octal number filename
chmod 777 kiruba.txt
we were given this permission to text file we can able to read, write and execute the specified file
Symbolic Mode
In the Absolute mode, we can change permissions for all 3 owners. In the symbolic mode, we can modify the permissions of a specific owner also make use of mathematical symbols to modify the Linux file permissions.
Operator
Description
+
Adds permission to a file or directory
–
Removes the permission
=
Sets the permission and overrides the permissions set earlier.
The various owners are represented as –
User Denotations
u
user/owner
g
group
o
other
a
all
Changing Ownership and Group:
changing the ownership of a file/directory we can use the following command
chown user filename
Eg: chown kiruba rman_backup.log