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';--删除数据

 

posted @ 2019-05-28 17:23  caribean  阅读(5337)  评论(0编辑  收藏  举报