Thursday, 12 December 2013

AUTOCOMMIT in SQL- Simple and Useful

DML Statements or Data Manipulation Language statements will not be committed unless they are committed explicitly, But if you use any data definition language (DDL) statement before or after , then Oracle Database issues an implicit COMMIT.

There is a provision in Oracle to commit every DML Transaction automatically once its run. This is called AUTOCOMMIT. We can also turn AUTOCOMMIT on and off based on our requirement.

Below are commands to check for AUTOCOMMIT.

Sunday, 8 December 2013

How to do Sorting in UNIX???

UNIX sort allows us to sort data in numeric, alphabetic and reverse order whether it’s of column or multiple columns with delimiters. Sort order can be restricted to individual columns and then merged to one single file. Sorting becomes handy in many situations.

Syntax
sort [options] [files...]

Sort Order Commands
Sort -o
Filename to write sorted output to file,
if not given then write to standard output.
Sort –d
Sort in dictionary order
Sort –n
Sort in numeric order(smallest first)
Sort -r
Sort in reverse order (z on top and a on bottom)
Sort –nr
Sort in  reverse numeric order
Sort +1
Sort starting with field 1 (starting from 0)
Sort +0.50
Sort starting with 50th character
Sort +1.5
Sort starting with 5th character of field 1
Sort -c
To see if a file is sorted (error message returned if not)
Sort -u
Suppress duplicate lines and output Identical input lines once.
Sort -M
Sort by month (JAN.FEB, MAR) Note that non-months are
sorted first and uppercase letters precede lowercase
letters for identical months.
Sort -k 1
Sort starting with the first character of the first field
and continuing through the end of the line.

Below we have explained some examples which will make it easy to understand and perform sorting.

1. Simple Sort  .i.e. sort in alphabetical order starting from the first character

Example 1
$ cat sort_number.txt
100
232
3
1
44444
99

$ sort sort_number.txt
1
100
232
3
44444
99

Note: The above records are sorted alphabetically, not mathematically sorted.Same with below

Example 2
$ cat myfile
Saina
Eesto
Jaffer
Michael

$ sort myfile
Eesto
Jaffer
Michael
Saina
Related Posts Plugin for WordPress, Blogger...

ShareThis