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
    );

  • 相关阅读:
    go 1.14.3安装micro报错处理记录
    关于redis哨兵机制的一些疑问
    TCP中异常关闭的情况记录
    mysql sleep 死锁例子
    ubuntu16.04 安装go
    innodb存储引擎之内存
    ubuntu16.04环境LNMP实现PHP5.6和PHP7.2
    mysql使用存储过程,批量生成测试数据
    mysql 关于字符串搜索的函数
    电脑上的windows键突然失灵了,肿么办
  • 原文地址:https://www.cnblogs.com/Yxxxxx/p/6720366.html
Copyright © 2011-2022 走看看