流殃的博客

| Comments

常用函数

if else

if 条件1 then 结果1
else 结果2 
end if

case when

# select中写的的case when
case 
when 条件1 then 结果1 
when 条件2 then 结果2
else 结果3
end
# where中写case when
#当状态等于2时判断表中的userid 是否和当前登录人id相等
 SELECT  * FROM  tbname t WHERE  1=1
AND  (CASE  WHEN  t.vc_state = '2'  THEN  t.vc_userId ELSE  当前登录人id END  ) = 当前登录人id

插入数据为乱码

#查询服务器的编码
select userenv('language') from dual;
# 查询数据库的编码
select * from V$NLS_PARAMETERS 
# 将服务器本地的编码在环境变量中进行设置
key :NLS_LANG
value:服务器编码

重启启动plsql,删除插入的乱码的数据,重新插入同样的数据,中文恢复正常

总数

查询总数没有办法在要分页的sql中直接查询出来,需要单独一个sql;

select count(1) from (查询语句)  

分页

image.png

Comments

评论