Tuesday 22 April 2014

Basic UNIX commands

How to create a new file ?

syntax : cat>filename
file data
file data
fild data

CTTL+D

How to rename existing file name ?

Syntax : mv oldfilename >> newfilename

How to change existing file content ?

Syntax: vi filename 

do all changes, if you want to save the file type the below command

:wq!

How to see the content of file ?

Syntax : cat <file name >

How to identify duplicate records in file ?(any file like DAT,CSV,TXT)

Syntex: cat <file name> | uniq -d

How to fetch unique records in file ?(any file like DAT,CSV,TXT)

Syntex: cat <file name> | uniq 







Tuesday 15 April 2014

What is the difference between union and union all ?    
Let us assume, i have two tables 
Table 1
Table 2 
Table 1 have the following records
1
2
3
4
5

Table 2 have the following records
5
6
7
8
9
10

Now fire the below query in SQL Assistant

Select * from table1 
Union
Select * from table2

Now we will get below records..
1
2
3
4
5
6
7
8
9
10

So we come to know, when ever we use union key word, it fetches only unique records.

Select * from table1
Union all
Select * from table 2

We well get the below records 

1
2
3
4
5
5
6
7
8
9
10

If you use union all keyword between two or more SQL statements, we will get the unique records as well as duplicates will fetches.

If any concern please drop a mail..