oracle中对排序的总结
select * from perexl order by nlssort(danwei,'NLS_SORT=SCHINESE_PINYIN_M');
-- 按部首排序
select * from perexl order by nlssort(danwei,'NLS_SORT=SCHINESE_STROKE_M');
-- 按笔画排序
select * from perexl order by nlssort(danwei,'NLS_SORT=SCHINESE_RADICAL_M');
--排序后获取第一行数据
select * from (select * from perexl order by
nlssort(danwei,'NLS_SORT=SCHINESE_PINYIN_M') )C where rownum=1
--降序排序
select * from perexl order by zongrshu desc
--升序排序
select * from perexl order by zongrshu asc
--将nulls始终放在最前
select * from perexl order by danwei nulls first
--将nulls始终放在最后
select * from perexl order by danwei desc nulls last
--decode函数比nvl函数更强大,同样它也可以将输入参数为空时转换为一特定值
select * from perexl order by decode(danwei,null,'单位是空', danwei)
-- 标准的rownum分页查询使用方法
select *from (select c.*, rownum rn from personnel c)where rn >= 1and rn <= 5
--在oracle语句rownum对排序分页的解决方案
--但是如果, 加上order by 姓名 排序则数据显示不正确
select *from (select c.*, rownum rn from personnel c order by 出生年月)where rn >=
1and rn <= 5
--解决方法,再加一层查询,则可以解决
select *from (select rownum rn, t.*from (select 姓名, 出生年月 from personnel order
by 出生年月 desc) t)where rn >= 1and rn <= 5
--如果要考虑到效率的问题,上面的还可以优化成(主要两者区别)
select *from (select rownum rn, t.*from (select 姓名,出生年月 from personnel order
by 出生年月 desc) t where rownum <= 10) where rn >= 3
--nvl函数可以将输入参数为空时转换为一特定值,下面就是当单位为空的时候转换成“单位是空”
select * from perexl order by nvl(danwei,'单位是空')
相关文档:
查询星期几:
select to_char(sysdate,'day') from dual;
查询几号:
select to_char(sysdate,'dd') from dual;
查询小时数:
select to_char(sysdate,'hh24') from dual;
查询时间:
select to_char(sysdate,'hh24:mi:ss') from dual;
查询日期时间:
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
查 ......
•何为审计
数据库审计,就是对数据库的活动做跟踪记录,主要包括数据库连接,SQL语句执行,数据库对象访问这些方面的跟踪记录。
•现实作用
安全控制、跟踪数据变化、程序BUG调试、自定义的数据汇总分析、操作日志
•存储方式
一种是存储在操作系统文件中,一种是存储在system表空间中的SYS.AUD$表中
......
•表分区技术是在超大型数据库(VLDB)中将大表及其索引通过分区(patition)的形式分割为若干较小、可管理的小块,并且每一分区可进一步划分为更小的子分区(sub partition)
•通过对表进行分区,可以获得以下的好处
–减少数据损坏的可能性
–各分区可以独立备份和恢复,增强了数据库的可管理性
......
package DBbean;
import java.sql.*;
public class ConnBean
{
private Connection con;
//初始化连接。
public ConnBean()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
......
Update SQLS will lead dead lock exception. Because by default, it use optimistic lock but not pessimistic lock.
Below description is exceprted from the attachment(It exceeds my image that this blog can not upload the attachment,hehe)
Optimistic locking offers an elegant solution to the problems o ......