PGSQL基本操做語句

update table01 set name='msq_all' where id=122;
--更新數據

insert into table01(id,dmcode,name,month) values (122,1,'app_all',201706) ;
--插入數據

SELECT * FROM table01 where 1=1 ORDER BY  app_name,flag asc/desc ;
--查詢數據而且排序

select * from persons limit 5 offset 0;
--查詢起點0開始查詢,返回5條數據

ORDER BY colname DESC NULLS FIRST / LAST;
--排序而且指定某數據排第一或最後

SELECT *,
(CASE WHEN province_type='省內'THEN 0 ELSE 1 END ) sn 
FROM 
table009 where 1=1 
ORDER BY  
CASE WHEN id='全省' and type='省內'  THEN 0 ELSE 1  END,sn;
--case...when..then...else... end

delete from table009 where id='11';--刪除數據
相關文章
相關標籤/搜索