SQL cheat sheet
general
create database .. owner ..;
drop database ..;
pragma table_info(..);
explain query plan ..;
create role .. with createdb login password ..;
grant select on .. to ..;
revoke all privileges on .. from ..;
create index if not exists .. on ..(..);
selection
select distinct .., ..
from .., .. A
where .. and ..
order by .. asc, .. desc;
select .., count(*) as c
from ..
where ..
group by ..
having ..;
select distinct ..
from ..
where .. in (select .. from .. where ..);
select .. limit ..
from ..
where exists (select * from .. where ..);
select avg(..)
from ..
where .. >= all (select .. from ..);
select ..
from ..
where .. is not null;
join
select ..
from .. join .. using (..)
where ..;
select ..
from .. join ..
on ..
where ..;
select ..
from (.. join .. on ..) join .. ;
select ..
from .. natual join ..
where .. ;
select ..
from .. left outer join .. ;
set operation
select * from .. where ..
union
select * from ..;
select * from ..
except
select * from ..;
database modification
insert into .. values (.., ..);
insert into .. select ..
from ..
where .. not in (select .. from ..);
delete from ..
where ...;
delete from ..
where except (select * from ... where ...);
update ..
set ..=..
where ..;
alter table ..
add .. ..;
alter table ..
drop column ..;
create table .....(
.. integer primary key,
.. text,
.. integer,
.. float,
foreign key(..) references ..(..)
);