zoukankan      html  css  js  c++  java
  • 单表查询

    create table testtable(
    Tname nvarchar2(10),
    Tage number(2)
    );
    commit;

    insert into testtable values('哈哈',32);
    insert into testtable values('嘿嘿',12);
    insert into testtable values('嘻嘻',21);
    insert into testtable values('佳佳',32);
    insert into testtable values('哈哈',32);
    insert into testtable values('嘿嘿',12);
    insert into testtable values('哈哈',32);
    insert into testtable values('嘿嘿',12);
    insert into testtable values('嘻嘻',21);
    insert into testtable values('qqqq',32);
    insert into testtable values('adcxzdf',32);
    insert into testtable values('safdfsfa',32);
    insert into testtable values('adfafgsdf',32);
    insert into testtable values('qerf',32);

    commit;
    ------------------------------
    --重复数据中查找唯一行
    select distinct * from testtable;
    --删除重复行
    delete testtable where rowid not in (
    select max(rowid) from testtable group by tname);

    --分页
    select * from (
    select rownum r,t.* from (select * from testtable)t where rownum<=15
    )where r>10;


    --由结果集建表
    create table temp_testtable as
    select * from testtable where 条件;

    --逻辑运算符or
    select * from(
    select rownum r,t.* from(select * from testtable)t
    ) where r=7 or r=10;

    --逻辑运算符and
    select * from(
    select rownum r,t.* from(select * from testtable)t
    ) where r>=6 and r<=12;

    --字符串连接||
    select tname||'_'||tage from testtable;

    select '姓名:'||tname||' '||'年龄:'||tage from testtable;

    --like模糊查询 % _

    select * from testtable where tname like '%';

    select * from testtable where tname like '%a%';

    select * from testtable where tname like '%a';

    select * from testtable where tname like 'a%';


    select * from testtable where tname like '___f';

    select * from testtable where tname like '%f_';

    --in子句
    select * from testtable where tage in(32,21);

    --null
    select * from testtable where tage is not null;

    --between...and
    select * from testtable where tage between 12 and 20;

    select * from testtable where tage>=12 and tage<20;
    select * from testtable where tage>12 and tage<20;

    select * from testtable where tage>12 and tage<40 and tname='qerf';


    ------------------------------
    select * from testtable;

    select rownum,tname from testtable;

    select rowid,tname,tage from testtable group by rowid,tname,tage;

    select * from testtable order by tage asc;

    select min(rowid) from testtable;

    delete testtable where rowid not in(
    select min(rowid) from testtable
    group by tname
    );

  • 相关阅读:
    java synchronized
    [多问几个为什么]为什么匿名内部类中引用的局部变量和参数需要final而成员字段不用?(转)
    Java中static、final用法小结(转)
    使用 Spring 2.5 注释驱动的 IoC 功能(转)
    (转载)Spring 注解@Component,@Service,@Controller,@Repository
    Spring中@Autowired注解、@Resource注解的区别
    控制反转和依赖注入模式(转)
    HDU 4758 Walk Through Squares (2013南京网络赛1011题,AC自动机+DP)
    HDU 4745 Two Rabbits (2013杭州网络赛1008,最长回文子串)
    HDU 4747 Mex (2013杭州网络赛1010题,线段树)
  • 原文地址:https://www.cnblogs.com/Yxxxxx/p/6720366.html
Copyright © 2011-2022 走看看