SQL Commands

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Commands  

create table (

 
);

primary key (a1,a2,........)  

foreign key (a1, a2,........) references r  

drop table r;  

delete from r;

OR

 
delete from r

where P;

alter table r add A1 A2;  

alter table r drop A1;  

select A1, A2,.....

from r1, r2,.........


 
where P;

distinct r  

where and, or, not  

as  

like 'intro% %intro% _ _ _ _ _ _%'

 
not like

*  

select

from
 
order by A1 asc/dsc, A2 asc/dsc,..........

between / not between  

union, intersect, except

 
union all, intersect all, except all

null arithmetic

 
null comparision

unknown and, or, not  

is null, is not null

 
is unknown, is not unknown

avg, sum, count, min, max

 
coalesce(_ , _)

group by  
Commands  

/* */ --  

select

from

where
 
group by

having;

A1 in r

 
not in (returns boolean)

some (r)

 
all (r)

< some, <= some, <> some  

exists r

 
not exists r (compare with in/ not in) (returns boolean)

unique r

 
not unique r (returns boolean)

with as  

insert into r

values ( , , ,)

OR
 
insert into r (A1,A2,A3......)

values ( , , , )

update r

set A =
 
where P;

update

set A = case

when P1 then _

 
when P2 then _

else

end

   

   

   

   
Commands  

   

   

   

   

   

   

   

   

   

   

   

   

You might also like