精华内容
下载资源
问答
  • 2018-07-26 23:16:38

    原文收藏于IT老兵驿站

    which命令用于查找并显示给定命令的绝对路径,环境变量$PATH中保存了查找命令时需要遍历的目录。which指令会在环境变量$PATH设置的目录里查找符合条件的文件。也就是说,使用which命令,就可以看到某个系统命令是否存在,以及执行的到底是哪一个位置的命令。

    备注

    今天有点累,也已经很晚了,总结一个较为简单的命令吧,20英里法则,每天尽量坚持往前走一点。

    命令功能

    which命令是查找某个命令的完整路径。它是用来在当前登录用户的$PATH环境变量记录的路径中查找可执行文件(即二进制文件)的路径。默认情况下,只返回第一个搜索结果。

    WHICH(1)                                                        General Commands Manual                                                       WHICH(1)
    
    NAME
           which - shows the full path of (shell) commands.

    命令格式

    which [选项] 命令

    实例

    实例:查看ls命令的位置

    [root@iZwz90drrwkerfi7bc8mqiZ ~]# which ls
    alias ls='ls --color=auto'
        /usr/bin/ls

    第一行输出暂时没有搞明白是哪里来的,第二行就是ls命令的位置了。

    更多相关内容
  • which用法总结

    2021-05-23 07:40:30
    哪些which用法及例句定语从句的关系代词 Which的用法: 若先行词指物则代替先行词在定语从句中充当主语或宾语.This is the pen which was given by my friend.先行词 指物代替先行词在定语从句中充当主语Thi...

    which是特殊疑问词,有多种用法.下面小编给大家整理了which的用法总结,希望大家喜欢!

    which释义

    adj.哪一个;哪一些

    pron.哪一个;哪些

    which用法及例句

    定语从句的关系代词 Which的用法: 若先行词指物则代替先行词在定语从句中充当主语或宾语.

    This is the pen which was given by my friend.

    先行词 指物代替先行词在定语从句中充当主语

    This is the pen which my friend gave to me.

    先行词 指物代替先行词在定语从句中充当宾语

    下面是他和that在定语从句中的区别及用法:

    that \which在代物时常常可以通用,但有时只宜于用which ,不用that

    (1) 关系代词前有介词时.

    This is the hotel in which you will stay.

    (2) 如有两个定语从句,其中一句的关系代词是that,另一句宜于用which.

    Let me show you the novel that I borrowed from the liberary which was newly open (新开放) to us.

    注意2that \which在代物时常常可以通用,但有时只宜于用that ,不用which.

    (1) 先行词是形容词最高级或者它的前面有形容词最高级时

    This is the best that has been used against air pollution(反对空气污染) in cities.

    English is the most difficult subject that you will learn during these years.

    (2) 先行词是序数词,或它的前面有一个序数词时

    He is the last person that I want to see.

    (3) 主句中已有疑问词时

    Which is the bike that you lost?

    (4) 先行词既有人又有物时

    The bike and its rider that had run over (撞倒了)an old man were taken to the police station.

    (5) 先行词是all,much,little,something,everything,anything,nothing,none,the one等代词时

    You should hand in all that you have.

    We haven’t got much that we can offer you.

    I mean the one that you talked about just now.

    (6) 先行词前面有only,any,few,little,no,all,one of,the same,the very等词修饰时

    The only thing that we can do is to give you some money.

    Li Ming is the only one that got full marks (满分)in our class.

    Li Ming is one of the students that want to be teachers in our class.

    (7) 有两个定语从句,其中一个关系代词已用which,另外一个宜用that

    Edison built up a factory(办了一个工厂) which produced things that had never been seen before.

    定语从句的关系副词 Where的用法:若先行词指地点且其在定语从句中充当地点状语.

    This is the house+I was born in the house. (=I was born there)

    介词短语 副词

    =This is the house where I was born.这就是我在那儿出生的房子.

    先行词 关系副词

    in which I was born.

    介词+关系代词

    which I was born in.

    关系代词

    这里作介宾的which和that可以省略

    that I wos born in charge的用法:

    1. 用作名词,注意以下用法:

    (1) 表示“收费”,是可数名词,通常(但不一定)用复数形式。如:

    Your charges are too high. 你收费太贵了。

    What is the charge in the hotel? / What are the charges in the hotel? 这旅馆收费多少?

    (2) 表示“负责”、“管理”,通常为不可数名词。如:

    Doctors have charge of the sick people. 医生负责照顾病人。

    Soon he will take charge of the department. 他很快会来负责管理这个部门。

    区别并比较(有 the 表被动,无 the 表主动):

    这个工厂由格林先生负责。

    Mr Green is in charge of this factory.

    This factory is in the charge of Mr Green.

    (3) 表示“控告”,是可数名词。如:

    They made a charge against the boss. 他们控告老板。

    He was arrested on a charge of murder. 他因谋杀罪被逮捕。

    2. 用作动词,无论是表示“收(费)”、“索(价)”还是“控告”等,都是及物动词。用法上注意:表示“收(费)”,通常与介词 for连用,并且可以带双宾语;而表示“指控”通常与介词 with 连用。如:

    He charged me 100 dollars for this coat. 这件外套他要我一百美元。

    The driver was charged with speeding. 司机被控超速驾车。

    比较:They charged me with robbery. / They charged robbery against me.

    character的3个主要用法解析:

    1. 表示人的“性格”或“品质”,或表示事物的“特性”或“特征”等,可用作可数或不可数名词。如:

    They are twins but have quite different characters. 他们虽为双胞胎,但性格却相当不同。

    He has a strong character. /He is a man of strong character.

    他有坚强的性格(他是个性格坚强的人)。D21/zn

    2. 表示小说或戏剧等中的“人物”或“角色”,是可数名词。如:

    Who is the main character in the play? 这出戏中的主要人物是谁?

    His characters are well drawn. 他作品中的人物刻画得很好。

    有时指“人”,根据语境有时有褒义(如指有个性的人等),有时有贬义(如指古怪或令人讨厌的人等)。如:

    He is quite a man. 他真是个怪人(他这人真有个性)。

    3. 表示“文字”,指书写符号或印刷符号等,是可数名词。如:

    He writes beautiful characters. 他能写一手漂亮的字。

    which用法小结

    1、在后置的非限制性定语从句中代替上文出现的事物或情况(单数或复数)。

    2、在问句中作为疑问代词,在名词从句中作为连接代词用,其含义为“哪个、哪些”。

    3、如果非限制性定语从句的先行词不是指主句内容,而是指具体的人、时间、地点,则不用which。

    4、关系代词that 和which 在定语从句中作主语和宾语,放在先行词和定语从句之间,起联系作用。

    5、which 在从句中作主语时,不能省略。作宾语时在口语中和非正式问题中经常省略。

    6、关系代词在主语从句中作主语时,从句的谓语动词的人称和数须和先行词一致。 Wheat is a plant that/which is grown in the north of China.

    7、引导非限制性定语从句时,通常要用which。

    She received an invitation from her boss, which came as a surprise.

    她收到了老板的邀请,这是她意想不到的。

    8、直接放在介词后作宾语时,通常要用which。

    The tool with which he is working is called a hammer.

    他干活用的那个工具叫做锤子。

    in which的用法

    in which只能用在定语从句中,等于where,在定语从句中作状语。

    比如:He lived in the house in which Tom once lived;He lived in the house where Tom once lived.

    which的用法总结相关文章:

    1.

    展开全文
  • ... 纸上得来终觉浅,绝知此事要躬行   博客园 首页 新闻 新随笔 联系 ...ORACLE WITH AS 用法 With查询语句不是以select开始的,而是以“WITH”关键字开头  可认为在真正进行查询之前预...

     

    https://www.cnblogs.com/mingforyou/p/8295239.html

    纸上得来终觉浅,绝知此事要躬行

     

    随笔- 536  文章- 0  评论- 120 

    ORACLE WITH AS 用法

    With查询语句不是以select开始的,而是以“WITH”关键字开头
        可认为在真正进行查询之前预先构造了一个临时表,之后便可多次使用它做进一步的分析和处理

    WITH Clause方法的优点
         增加了SQL的易读性,如果构造了多个子查询,结构会更清晰;更重要的是:“一次分析,多次使用”,这也是为什么会提供性能的地方,达到了“少读”的目标。

         第一种使用子查询的方法表被扫描了两次,而使用WITH Clause方法,表仅被扫描一次。这样可以大大的提高数据分析和查询的效率。

         另外,观察WITH Clause方法执行计划,其中“SYS_TEMP_XXXX”便是在运行过程中构造的中间统计结果临时表。

     

    语法:

    with tempName as (select ....)
    select ...

     

    复制代码

    --针对一个别名
    with tmp as (select * from tb_name)
    
    --针对多个别名
    with
       tmp as (select * from tb_name),
       tmp2 as (select * from tb_name2),
       tmp3 as (select * from tb_name3),
       …

    复制代码

     

    复制代码

    --相当于建了个e临时表
    with e as (select * from scott.emp e where e.empno=7499)
    select * from e;
     
    --相当于建了e、d临时表
    with
         e as (select * from scott.emp),
         d as (select * from scott.dept)
    select * from e, d where e.deptno = d.deptno;

    复制代码

     

    其实就是把一大堆重复用到的sql语句放在with as里面,取一个别名,后面的查询就可以用它,这样对于大批量的sql语句起到一个优化的作用,而且清楚明了。

    向一张表插入数据的 with as 用法:

    insert into table2
    with
        s1 as (select rownum c1 from dual connect by rownum <= 10),
        s2 as (select rownum c2 from dual connect by rownum <= 10)
    select a.c1, b.c2 from s1 a, s2 b where...;

    with as 相当于虚拟视图。

    with as短语,也叫做子查询部分(subquery factoring),可以让你做很多事情,定义一个sql片断,该sql片断会被整个sql语句所用到。

    有的时候,是为了让sql语句的可读性更高些,也有可能是在union all的不同部分,作为提供数据的部分。
      
    特别对于union all比较有用。

    因为union all的每个部分可能相同,但是如果每个部分都去执行一遍的话,则成本太高,所以可以使用with as短语,则只要执行一遍即可。

    如果with as短语所定义的表名被调用两次以上,则优化器会自动将with as短语所获取的数据放入一个temp表里,如果只是被调用一次,则不会。

    而提示materialize则是强制将with as短语里的数据放入一个全局临时表里。

    很多查询通过这种方法都可以提高速度。

    复制代码

    with
        sql1 as (select to_char(a) s_name from test_tempa),
        sql2 as (select to_char(b) s_name from test_tempb where not exists (select s_name from sql1 where rownum=1))
    select * from sql1
    union all
    select * from sql2
    union all
    select 'no records' from dual
           where not exists (select s_name from sql1 where rownum=1)
           and not exists (select s_name from sql2 where rownum=1);

    复制代码

    with as优点
    增加了sql的易读性,如果构造了多个子查询,结构会更清晰;
    更重要的是:“一次分析,多次使用”,这也是为什么会提供性能的地方,达到了“少读”的目标

     

    分类: Oracle

    好文要顶 关注我 收藏该文  

    残星
    关注 - 6
    粉丝 - 433

    +加关注

    1

    0

    « 上一篇:Oracle创建Database Link
    » 下一篇:提示-bash: telnet: command not found的解决方法

    posted @ 2018-01-16 10:21 残星 阅读(17238) 评论(0) 编辑 收藏

    刷新评论刷新页面返回顶部

    https://www.cnblogs.com/mingforyou/p/8295239.html

     

     

     

     

     

     

    https://blog.csdn.net/baidu_37107022/article/details/79619809

    深入理解和使用Oracle中with as语句以及与增删改查的结合使用

    2018年03月20日 00:15:29 Java仗剑走天涯 阅读数:1859更多

    所属专栏: ORACLE

     版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/baidu_37107022/article/details/79619809

    WITH AS短语,也叫做子查询部分(subquery factoring),可以做很多事情,定义一个SQL片断,该SQL片断会被整个SQL语句所用到。有的时候,是为了让SQL语句的可读性更高些,也有可能是在UNION ALL的不同部分,作为提供数据的部分。

    特别对于UNION ALL比较有用。因为UNION ALL的每个部分可能相同,但是如果每个部分都去执行一遍的话,则成本太高,所以可以使用WITH AS短语,则只要执行一遍即可。如果WITH AS短语所定义的表名被调用两次以上,则优化器会自动将WITH AS短语所获取的数据放入一个TEMP表里,如果只是被调用一次,则不会。而提示materialize则是强制将WITH AS短语里的数据放入一个全局临时表里。

     

    一、with as 语法

    单个语法:

    with tempName as (select ....)

    select ...

     

    多个语法:

    with tempName1 as (select ....),

    tempName2 as (select ....),

    tempName3 as (select ....) ...

    select ... 

     

    With查询语句不是以select开始的,而是以“WITH”关键字开头

    可认为在真正进行查询之前预先构造了一个临时表TT,之后便可多次使用它做进一步的分析和处理

     

    二、WITH AS实例

    例:现在要从1-19中得到11-14。一般的sql如下:

    select * from

    (

                --模拟生一个20行的数据

                 SELECT LEVEL AS lv

                   FROM DUAL

             CONNECT BY LEVEL < 20

    ) tt

     WHERE tt.lv > 10 AND tt.lv < 15

     

    使用With as 的SQL为:

    with TT as( --模拟生一个20行的数据 SELECT LEVEL AS lv FROM DUAL CONNECT BY LEVEL < 20 ) select lv from TTWHERE lv > 10 AND lv < 15

     

    多个临时表实例:

    WITH

    T3 AS

    (

    SELECT T1.ID, T1.CODE1, T2.DESCRIPTION

    FROM TB_DATA T1, TB_CODE T2

    WHERE T1.CODE1 = T2.CODE

    ),

    T4 AS

    (

    SELECT T1.ID, T1.CODE2, T2.DESCRIPTION

    FROM TB_DATA T1, TB_CODE T2

    WHERE T1.CODE2 = T2.CODE

    )

    SELECT T3.ID, T3.DESCRIPTION, T4.DESCRIPTION

    FROM T3, T4

    WHERE T3.ID = T4.ID

    ORDER BY ID;  

     

    三、WITH Clause方法的优点

         增加了SQL的易读性,如果构造了多个子查询,结构会更清晰;更重要的是:“一次分析,多次使用”,这也是为什么会提供性能的地方,达到了“少读”的目标。

         第一种使用子查询的方法表被扫描了两次,而使用WITH Clause方法,表仅被扫描一次。这样可以大大的提高数据分析和查询的效率。

         另外,观察WITH Clause方法执行计划,其中“SYS_TEMP_XXXX”便是在运行过程中构造的中间统计结果临时表。

     

    四、WITH AS 与增删改查结合用法

    注意:1.with必须紧跟引用的select语句

    2.with创建的临时表必须被引用,否则报错

    4.1与select查询语句结合使用

    查询同一个单据编号对应的借款单和核销单中,借款金额不相等的单据

     
    1. with verificationInfo as

    2. (select ment.fnumber,

    3. sum(t.famount) vLoanSum,

    4. ment.fnumber "单据编号",

    5. sum(t.famount) "核销单中借款总额"

    6. from shenzhenjm.t_finance_expenseremburseitem t

    7. left join shenzhenjm.t_finance_expenserembursement ment

    8. on ment.fid = t.fkrembursementid

    9. where 1 = 1

    10. group by ment.fnumber),

    11.  
    12. loanInfo as

    13. (select ment.fnumber,

    14. sum(t.famount) loanSum,

    15. ment.fnumber "单据编号",

    16. sum(t.famount) "借款单中借款总额"

    17. from shenzhenjm.t_finance_expenseremburseitem2 t

    18. left join shenzhenjm.t_finance_expenserembursement ment

    19. on ment.fid = t.fkrembursementid

    20. where 1 = 1

    21. group by ment.fnumber)

    22.  
    23. select *

    24. from verificationInfo v, loanInfo l

    25. where l.fnumber = v.fnumber

    26. and l.loanSum != v.vLoanSum;

    4.2与insert结合使用

    如下的with as语句,不能放在insert前,而是放在紧接着要调用的地方前

    要求将同一个单据编号对应的借款单和核销单中,借款金额不相等的单据,对应的借款单删除,并将对应的核销单插入到借款单表中 (借款单和核销单表结构完全一样)

     
    1. insert into T_finance_ExpenseRemburseItem2

    2. (FID,

    3. FKREMBURSEMENTID,

    4. FAMOUNT,

    5. FKCREATEBYID,

    6. FCREATETIME,

    7. FKCUID,

    8. FKCOSTTYPEID,

    9. FCOSTTYPENAME)

    10.  
    11. with verificationInfo as

    12. (select ment.fnumber,

    13. sum(t.famount) vLoanSum,

    14. ment.fnumber "单据编号",

    15. sum(t.famount) "核销单中借款总额"

    16. from shenzhenjm.t_finance_expenseremburseitem t

    17. left join shenzhenjm.t_finance_expenserembursement ment

    18. on ment.fid = t.fkrembursementid

    19. where 1 = 1

    20. group by ment.fnumber),

    21.  
    22. loanInfo as

    23. (select ment.fnumber,

    24. sum(t.famount) loanSum,

    25. ment.fnumber "单据编号",

    26. sum(t.famount) "借款单中借款总额"

    27. from shenzhenjm.t_finance_expenseremburseitem2 t

    28. left join shenzhenjm.t_finance_expenserembursement ment

    29. on ment.fid = t.fkrembursementid

    30. where 1 = 1

    31. group by ment.fnumber)

    32.  
    33. select sys_guid(),

    34. ment.fid,

    35. t.famount,

    36. ment.fkcreatebyid,

    37. ment.fcreatetime,

    38. ment.fkcuid,

    39. t.fkcosttypeid,

    40. t.fcosttypename

    41. from T_finance_ExpenseRemburseItem t

    42. left join t_finance_expenserembursement ment

    43. on ment.fid = t.fkrembursementid

    44. where 1 = 1

    45. and exists (select *

    46. from verificationInfo v, loanInfo l

    47. where l.fnumber = v.fnumber

    48. and l.loanSum != v.vLoanSum

    49. and v.fnumber = ment.fnumber);

    4.3 与delete删除结合使用

     
    1. delete from t_finance_expenseremburseitem2 item2

    2.  where exists(with temp as (select t.fnumber,

    3.                              sum(item1.famount) vloanSum,

    4.                              sum(item1.frealityamount) vSum,

    5.                              sum(item2.famount) loanSum

    6.                         from t_finance_expenserembursement t

    7.                         left join t_finance_expenseremburseitem item1

    8.                           on item1.fkrembursementid = t.fid

    9.                         left join t_finance_expenseremburseitem2 item2

    10.                           on item2.fkrembursementid = t.fid

    11.                        where 1 = 1

    12.                          and t.frembursementtype = 'LOAN_REPORT'

    13.                          and to_char(t.fcreatetime, 'yyyy') > '2017'

    14.                        group by t.fnumber

    15.                        order by t.fnumber asc)

    16.  

    17.    select 1

    18.      from temp t

    19.      left join t_finance_expenserembursement ment

    20.        on t.fnumber = ment.fnumber

    21.      left join t_finance_expenseremburseitem2 item

    22.        on item.fkrembursementid = ment.fid

    23.     where t.vloanSum != t.loanSum

    24.       and item.fid = item2.fid);

    25.  

     

    4.4与update结合使用

     
    1. update dest b

    2. set b.NAME =

    3. (with t as (select * from temp)

    4. select a.NAME from temp a where a.ID = b.ID)

     

     收藏 

     分享

    https://blog.csdn.net/baidu_37107022/article/details/79619809

     

     

     

     

     

     

    https://blog.csdn.net/idomyway/article/details/79037178

    Oracle WITH AS 用法

    2018年01月11日 18:15:55 idomyway 阅读数:2846

     版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/idomyway/article/details/79037178

    前言

     可以把WITH AS 的用法看成赋值的用法,以减少SQL语句的冗余。
     当我们在SQL语句中频繁的利用某一个Select查询语句作为数据源时,我们可以用WITH AS 的用法进行简写
     增加了SQL的易读性,如果构造了多个子查询,结构会更清晰;更重要的是:“一次分析,多次使用”。
    
    • 1
    • 2
    • 3

    语法

    with tempName1 as (select ....),tempName2 as (select ....)
    select ...from  tempName 
    • 1
    • 2

    例子

    例子:

    //普通使用方法
    Select * from (
        select name ,age from stu
        union 
        select name,age from tech
        union
        …
    )
    
    //wtih as 
    with schoolPeople as (
        select name ,age from stu
        union 
        select name,age from tech
        union
        …
    )
    select * from schoolPeople
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    注意事项

    • ① 子查询可重用相同或者前一个with查询块,通过select调用(with子句也只能被select调用)
    • ② with子句的查询输出存储到用户临时表空间,一次查询,到处使用
    • ③ 同级select前有多个查询定义,第一个用with,后面的不用with,并且用逗号分割
    • ④ 最后一个with查询块与下面的select调用之间不能用逗号分割,只通过右括号分离,with子句的查询必须括号括起
    • ⑤如果定义了with子句,而在查询中不使用,则会报ora-32035错误,只要后面有引用的即可,不一定在select调用,在后with查询块引用也是可以的
    • ⑥ 前面的with子句定义的查询在后面的with子句中可以使用,但是一个with子句内部不能嵌套with子句
    • ⑦ with查询的结果列有别名,引用时候必须使用别名或者*

     收藏 

     分享

    https://blog.csdn.net/idomyway/article/details/79037178

     

     

     

     

     

     

     

    https://www.cnblogs.com/LinXuDong/p/6077905.html

    随笔- 5  文章- 0  评论- 1 

    Oracle with as 用法

      项目中早些时间,有个oracle查询语句写的极其复杂,因为数据量小的关系,当时也并没有怎么在意,回来随着时间过去,客户数据库数量越来越大,那段语句的劣性就体现的非常明显。优化时,发现查询关系逻辑混乱又复杂(虽然数据查询结果并没有错),多个类似的子查询嵌套,导致查询性能变的很低。

      寻求资料知道ORACLE有个WITH as 用法及其好用 

         写法大致如下:

      WITH  query1 AS

    (select ...from ....where ..),

    query2  AS

    (select...from ...where..),

    query3 AS

    (select...from ...where..)

    SELECT ...FROM query1,quer2,query3 

    where ....;

      上述代码,每一个逗号(必不可少)代表一段子查询,观察执行计划发现,执行时with as 中的子查询结果会以临时表的形式存在。

    这样写每段子查询相应的表仅会被检索一次,不会像原来嵌套的一样反复扫描相同的表,达到了“少读的目的”,大大提高了数据分析以及查询效率.

    分类: Oracle

    好文要顶 关注我 收藏该文  

    Hey,Man!
    关注 - 3
    粉丝 - 2

    +加关注

    0

    0

    « 上一篇:动态加载DLL对接第三方接口
    » 下一篇:dev gridlookupedit

    posted @ 2016-11-18 15:25 Hey,Man! 阅读(6104) 评论(1) 编辑 收藏

    https://www.cnblogs.com/LinXuDong/p/6077905.html

     

     

     

     

     

     

    https://blog.csdn.net/huangbaokang/article/details/78474614

    ORACLE WITH AS 用法

    2017年11月08日 09:00:52 黄宝康 阅读数:1996

    语法:

    with tempName as (select ....)
    select ...
    • 1
    • 2

    例:现在要从1-19中得到11-14。一般的sql如下:

    select * from
    (
                --模拟生一个20行的数据
                 SELECT LEVEL AS lv
                   FROM DUAL
             CONNECT BY LEVEL < 20
    ) tt
     WHERE tt.lv > 10 AND tt.lv < 15
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    使用With as 的SQL为:

    with TT as(
                    --模拟生一个20行的数据
                     SELECT LEVEL AS lv
                     FROM DUAL
                    CONNECT BY LEVEL < 20
                 ) 
    select lv from TT
    WHERE lv > 10 AND lv < 15
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    With查询语句不是以select开始的,而是以“WITH”关键字开头 
    可认为在真正进行查询之前预先构造了一个临时表TT,之后便可多次使用它做进一步的分析和处理

    WITH Clause方法的优点

     增加了SQL的易读性,如果构造了多个子查询,结构会更清晰;更重要的是:“一次分析,多次使用”,这也是为什么会提供性能的地方,达到了“少读”的目标。
    
     第一种使用子查询的方法表被扫描了两次,而使用WITH Clause方法,表仅被扫描一次。这样可以大大的提高数据分析和查询的效率。
    
     另外,观察WITH Clause方法执行计划,其中“SYS_TEMP_XXXX”便是在运行过程中构造的中间统计结果临时表。
    
    • 1
    • 2
    • 3
    • 4
    • 5

    专业墙纸贴纸厨房用具装饰出售,本人网店经营

    博客对你有用记得访问下哦,增加下访问量,如有需要可以下单购买哦^_^。https://item.taobao.com/item.htm?id=569617707364

     收藏 

     分享

    https://blog.csdn.net/huangbaokang/article/details/78474614

     

     

     

     

     

     

    https://blog.csdn.net/zhu2695/article/details/79698568

    关于oracle with table as的用法

    2018年03月26日 15:16:16 zhu2695 阅读数:687

    最近在论坛经常看到有人使用with table as语句,一般都是构建一个临时表,用于测试,经研究此语句的用法我理解有以下好处:

    1)  不用实际建表,可以轻松构建一个临时表,通过对这个表的处理测试一些功能;

    例如:with t as (

    select '010-82696948' telfrom dualunionall

    select'020 82167684'from dualunion all

    select'010-62102147\62104404'from dualunion all

    select'0860476-82321383'from dualunion all

    select'020-28876096'from dualunion all

    select'010-67260464-分机'from dual)

    select '086-0'||regexp_replace(replace(regexp_substr(tel,'[0-9]+[- ][0-9]{7}',1,1),'','-'),'^[0]*86[0]|^0','')from t;

    --对各种格式电话号码做规范化处理

     

    2)  复杂的查询会产生很大的sql,with table as语法可以把一些公共查询提出来,也可以显示一个个中间结果,可以使整个sql语句显得有条理些,可读性提高;

    3)  前面的中间结果可以被语句中的select或后面的中间结果表引用,类似于一个范围仅限于本语句的临时表,在需要多次查询某中间结果时可以提升效率 ,特别是对一些大数据量的表做多项统计时,可以大大提高效率。 

    例如: 

    with a as (select * from dba_objects where 某些查询条件),
         b as (select * from a where 某些查询条件)
         select * from b , a  where 其它查询条件;

    再比如:

    with tb as (select * from dba_objects where 某些查询条件),
              select count(*) from tb  where 其它查询条件1

              union

              select count(*) from tb  where 其它查询条件2

              union

              select count(*) from tb  where 其它查询条件3;

    1、语法

    with table as 相当于建个临时表(用于一个语句中某些中间结果放在临时表空间的SQL语句),Oracle 9i 新增WITH语法,可以将查询中的子查询命名,放到SELECT语句的最前面。

    语法就是
    with tempname as (select ....)
    select ...

    例子:
    with t as (select * from emp where depno=10)
    select * from t where empno=xxx

    with wd as (select did,arg(salary) 平均工资 from work group by did),
    em as (select emp.*,w.salary from emp left join work w on emp.eid = w.eid)
    select * from wd,em where wd.did =em.did and wd.平均工资>em.salary;

    =============================================================

     注意:这个临时表只能用于查询,不能用于更新,如:

    ith tt as ( select to_char(sysdate,'yyyymmdd') rq from dual )
    update song_temp set code=( select rq from tt) where code='11';

    这个语句会报错:ora-00928: 缺失select关键字!

     

    2、何时被清除

    临时表不都是会话结束就自动被PGA清除嘛! 但with as临时表是查询完成后就被清除了!
    23:48:58 SCOTT@orcl> with aa as(select * from dept)
    23:57:58   2  select * from aa;

        DEPTNO DNAME          LOC
    ---------- -------------- -------------
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON

    已用时间:  00: 00: 00.12
    23:58:06 
    SCOTT@orcl> select * from aa;
    select * from aa
                  *
    第 1 行出现错误:
    ORA-00942: 表或视图不存在


    已用时间:  00: 00: 00.02
    23:58:14 
    SCOTT@orcl>

    3、举例

    假定有张很大的表,有几年来的经营数据,数据量很大。如果要统计一段时间内的邮件状态,如果都从总表中统计,效率一定不高,而采用with tablename as 语句,先将一段时间内的数据取出来,再进行统计就会简单的多。

     

    with tb as (

    select b.city,a.mail_num,a.rcv_area from tb_evt_mail_clct a, tb_jg b

             where a.clct_date = to_date('20110816', 'yyyymmdd')

               and (a.rcv_area like '23%' or a.rcv_area like '24%')

               and a.clct_bureau_org_code = b.zj_code

               and not exists (select 1 from tb_evt_dlv c

                     where c.mail_num = a.mail_num

                       and c.dlv_sts_code = 'I')

                       )   -- 提取出查询数据

    select aa.city 收寄城市, aa.wtt 未妥投, bb.wtd 未投递, cc.wkc 未开拆

      from (select tb.city, count(*) wtt

              from tb

             group by tb.city) aa  -- 统计1

      left join (select tb.city, count(*) wtd

                   from tb

                    where  not exists

                  (select 1 from tb_evt_dlv c

                          where c.mail_num = tb.mail_num

                            and (c.dlv_sts_code = 'H' or c.dlv_sts_code = 'I'))

                  group by tb.city) bb on bb.city = aa.city  -- 统计2

      left join (select tb.city, count(*) wkc 

                   from tb

                  where not exists

                  (select 1  from tb_evt_dlv c

                          where c.mail_num = tb.mail_num

                            and (c.dlv_sts_code = 'H' or c.dlv_sts_code = 'I'))

                    and not exists

                  (select 1 from tb_evt_bag_mail_rela e

                          where e.mail_num = tb.mail_num

                            and e.bag_actn_code = '2'

                            and e.deal_org_code like

                                substr(tb.rcv_area, 1, 4) || '%')

                  group by tb.city) cc on cc.city = aa.city -- 统计3

     收藏 

     分享

    https://blog.csdn.net/zhu2695/article/details/79698568

     

     

     

     

     

     

    https://yq.aliyun.com/ziliao/194025

    1. 云栖社区>
    2. >
    3. 正文

    ORACLE WITH AS 用法

    作者:用户 来源:互联网 时间:2018-05-18 20:37:23

    sqloracleinsertoracle10gquerySubquery

    ORACLE WITH AS 用法 -摘要: 本文讲的是ORACLE WITH AS 用法, 原文传送门:http://blog.csdn.net/wh62592855/archive/2009/11/06/4776631.aspx   记得以前在论坛里看到inthirties用到过WITH AS

    教程 云栖大会 Mysql 备案 文档 域名 whois查询 PHP教程 备份 互联网大学 云教程

    原文传送门:http://blog.csdn.net/wh62592855/archive/2009/11/06/4776631.aspx

     

    记得以前在论坛里看到inthirties用到过WITH AS这个字眼,当时没特别在意。今天在一个帖子里又看到有人用这个,所以就去网上搜了搜相关内容,自己小试了一把,写下来,方便以后忘了的话学习。

    ===================================================================================

    先举个例子吧:

    有两张表,分别为A、B,求得一个字段的值先在表A中寻找,如果A表中存在数据,则输出A表的值;如果A表中不存在,则在B表中寻找,若B表中有相应记录,则输出B表的值;如果B表中也不存在,则输出"no records”字符串。

    with sql1 as (select to_char(a) s_name from test_tempa), sql2 as (select to_char(b) s_name from test_tempb where not exists (select s_name from sql1 where rownum=1)) select * from sql1 union all select * from sql2 union all select 'no records' from dual where not exists (select s_name from sql1 where rownum=1) and not exists (select s_name from sql2 where rownum=1);

    再举个简单的例子

    with a as (select * from test)

    select * from a;

    其实就是把一大堆重复用到的SQL语句放在with as 里面,取一个别名,后面的查询就可以用它

    这样对于大批量的SQL语句起到一个优化的作用,而且清楚明了

    下面是搜索到的英文文档资料

    About Oracle WITH clause
    Starting in Oracle9i release 2 we see an incorporation of the SQL-99 “WITH clause”, a tool for materializing subqueries to save Oracle from having to re-compute them multiple times.

    The SQL “WITH clause” is very similar to the use of Global temporary tables (GTT), a technique that is often used to improve query speed for complex subqueries. Here are some important notes about the Oracle “WITH clause”:

       • The SQL “WITH clause” only works on Oracle 9i release 2 and beyond.
       • Formally, the “WITH clause” is called subquery factoring
       • The SQL “WITH clause” is used when a subquery is executed multiple times
       • Also useful for recursive queries (SQL-99, but not Oracle SQL)

    To keep it simple, the following example only references the aggregations once, where the SQL “WITH clause” is normally used when an aggregation is referenced multiple times in a query.
    We can also use the SQL-99 “WITH clause” instead of temporary tables. The Oracle SQL “WITH clause” will compute the aggregation once, give it a name, and allow us to reference it (maybe multiple times), later in the query.

    The SQL-99 “WITH clause” is very confusing at first because the SQL statement does not begin with the word SELECT. Instead, we use the “WITH clause” to start our SQL query, defining the aggregations, which can then be named in the main query as if they were “real” tables:

    WITH
    subquery_name
    AS
    (the aggregation SQL statement)
    SELECT
    (query naming subquery_name);

    Retuning to our oversimplified example, let’s replace the temporary tables with the SQL “WITH  clause”:

    WITH
    sum_sales AS
      select /*+ materialize */
        sum(quantity) all_sales from stores
    number_stores AS
      select /*+ materialize */
        count(*) nbr_stores from stores
    sales_by_store AS
      select /*+ materialize */
      store_name, sum(quantity) store_sales from
      store natural join sales
    SELECT
       store_name
    FROM
       store,
       sum_sales,
       number_stores,
       sales_by_store
    where
       store_sales > (all_sales / nbr_stores)
    ;

    Note the use of the Oracle undocumented “materialize” hint in the “WITH clause”. The Oracle materialize hint is used to ensure that the Oracle cost-based optimizer materializes the temporary tables that are created inside the “WITH” clause. This is not necessary in Oracle10g, but it helps ensure that the tables are only created one time.

    It should be noted that the “WITH clause” does not yet fully-functional within Oracle SQL and it does not yet support the use of “WITH clause” replacement for “CONNECT BY” when performing recursive queries.

    To see how the “WITH clause” is used in ANSI SQL-99 syntax, here is an excerpt from Jonathan Gennick’s great work “Understanding the WITH Clause” showing the use of the SQL-99 “WITH clause” to traverse a recursive bill-of-materials hierarchy
    The SQL-99 “WITH clause” is very confusing at first because the SQL statement does not begin with the word SELECT. Instead, we use the “WITH clause” to start our SQL query, defining the aggregations, which can then be named in the main query as if they were “real” tables:

    WITH
    subquery_name
    AS
    (the aggregation SQL statement)
    SELECT
    (query naming subquery_name);


    Retuning to our oversimplified example, let’s replace the temporary tables with the SQL “WITH” clause”:

    =================================================================================

    下面自己小试一把,当然,一点都不复杂,很简单很简单的例子,呵呵。

    SQL> create table t2(id int); Table created. SQL> create table t3(id int); Table created. SQL> insert into t2 values(1); 1 row created. SQL> insert into t2 values(2); 1 row created. SQL> insert into t3 values(3); 1 row created. SQL> commit; Commit complete. SQL> select * from t2; ID ---------- 1 2 SQL> select * from t3; ID ---------- 3 SQL> with 2 sql1 as (select * from t2), 3 sql2 as (select * from t3) 4 select * from t2 5 union 6 select * from t3; sql2 as (select * from t3) * ERROR at line 3: ORA-32035: unreferenced query name defined in WITH clause --从这里可以看到,你定义了sql1和sql2,就得用它们哦,不然会报错的。 SQL> with 2 sql1 as (select * from t2), 3 sql2 as (select * from t3) 4 select * from sql1 5 union 6 select * from sql2; ID ---------- 1 2 3 --下面加个WHERE条件试试 SQL> with 2 sql1 as (select * from t2), 3 sql2 as (select * from t3) 4 select * from sql1 5 union 6 select * from sql2 7 where id in(2,3); ID ---------- 1 2 3 --奇怪。为什么加了WHERE条件还是输出ID=1的记录了,继续往下看: SQL> with 2 sql1 as (select * from t2), 3 sql2 as (select * from t3) 4 select * from sql1 5 where id=3 6 union 7 select * from sql2 8 where id=3; ID ---------- 3 --可以看到,每个条件是要针对每个SELECT语句的。

    好了就先记这些吧,以后看到了新的用法再补充。

    以上是ORACLE WITH AS 用法的全部内容,在云栖社区的博客、问答、云栖号、人物、课程等栏目也有ORACLE WITH AS 用法的相关内容,欢迎继续使用右上角搜索按钮进行搜索sql , oracle , insert , oracle10g , query Subquery ,以便于您获取更多的相关知识。

    上一篇 1 2 3 4 下一篇

    分享到:

    相关文章

    https://yq.aliyun.com/ziliao/194025

     

     

     

     

     

     

    https://www.cnblogs.com/sheng-jie/p/8795207.html

    『___知多少』

    不做调包侠!

    随笔 - 110  文章 - 0  评论 - 678

    Oracle:WITH AS () Merge ?

    WITH AS 语法在SQL SERVER 和ORACLE数据库上均支持,主要用于子查询。语法如下:

    WITH expression_name [ ( column_name [,...n] ) ]
    AS
    ( CTE_query_definition )
    --只有在查询定义中为所有结果列都提供了不同的名称时,列名称列表才是可选的。
    --运行 CTE 的语句为:
    SELECT <column_list> FROM expression_name;

    但其语句在两个数据库的应用却有所不同,比如在SQL SERVER 数据库上,这种语法叫做CTE,CTE后面必须直接跟使用CTE的SQL语句(如select、insert、update、merge等),否则,CTE将失效。

    但是对于Oracle数据库而言,却有一个限制比较头疼,就是WITH AS后面需要紧跟SELECT语句。那如果需要执行MERGE该如何是好呢?
    简单,将MERGE 语句提前即可。

    举例说明:

    MERGE INTO #TEMP1 A
    USING (
    WITH SUMORDER AS 
           (SELECT PRODUCTID, SUM(AMOUNT) TOTAL 
            FROM ORDER GROUP BY PRODUCTID)
           SELECT * FROM SUMORDER
    ) B ON (A.PRODUCTID = B.PRODUCTID)
    WHEN MATCHED THEN UPDATE SET A.TOTAL = B.TOTAL;

    同理,适用于其他SQL语句!

    关注我的公众号『微服务知多少』,我们微信不见不散。 
    阅罢此文,如果您觉得本文不错并有所收获,请【打赏】或【推荐】,也可【评论】留下您的问题或建议与我交流。 你的支持是我不断创作和分享的不竭动力!

    作者:『圣杰』

    出处:http://www.cnblogs.com/sheng-jie/

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。

    分类: Database

    好文要顶 关注我 收藏该文  

    『圣杰』
    关注 - 76
    粉丝 - 656

    荣誉:推荐博客

    +加关注

    0

    0

    « 上一篇:ASP.NET Core知多少(6):VS Code联调Angular + .NetCore
    » 下一篇:ASP.NET Core知多少(7):对重复编译说NO -- dotnet watch

    posted @ 2018-04-11 13:40 『圣杰』 阅读(350) 评论(0) 编辑 收藏

    刷新评论刷新页面返回顶部

    https://www.cnblogs.com/sheng-jie/p/8795207.html

     

     

     

     

     

    https://wenku.baidu.com/view/434c07caf01dc281e43af034.html

    关于oracle with as用法

    https://wenku.baidu.com/view/434c07caf01dc281e43af034.html

     

     

     

     

     

     

     

     

     

     

     

     

     

    展开全文
  • python-with open函数的用法

    万次阅读 多人点赞 2019-06-28 11:04:17
    Using with is also much shorter than writing equivalent try-finally blocks,同时使用with也比写 try-finally blocks更简短。 with open('workfile') as f: ... read_data = f.read() f.closed True 如果 ...

    原文地址:https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
    本文为学习过程中顺带的翻译,大家一起分享下~

    7.2. Reading and Writing Files
    open() 函数返回一个file object,通常需要传入两个参数 filename和mode—— open(filename, mode).

    f = open(‘workfile’, ‘w’)

    第一个参数filename是包含文件地址的str
    第二个参数mode用来指定文件被使用的方式,The mode argument is optional;如果不指定则默认为mode= ‘r’ 即只读模式
    其中 mode=‘r’ 意味着 文件只是用来读入python ,
    mode=‘w’ for only writing (如果写入之后的文件和之前的文件同名,则之前的那个文件会被擦除、覆盖an existing file with the same name will be erased)
    mode=‘a’ opens the file for appending; any data written to the file is automatically added to the end任何append进file的数据都被自动加到文件末尾位置
    mode=‘r+’ opens the file for both reading and writing读写均可.

    通常来说文件以text模式打开,这意味着我们读写string的文件是以一种特定的encoding方式进行编码的。Normally, files are opened in text mode, that means, you read and write strings from and to the file, which are encoded in a specific encoding. If encoding is not specified, the default is platform dependent (see open())如果encoding方式没有指定,那么通常默认encoding方式是平台相关的.
    ‘b’ appended to the mode opens the file in binary mode: now the data is read and written in the form of bytes objects. **This mode should be used for all files that don’t contain text.**对于不包含text的file,都应该用mode='b’模式用binary mode to open the file.

    In text mode, the default when reading is to convert platform-specific line endings (\n on Unix, \r\n on Windows) to just \n
    在text mode下读取时会默认将平台特定的每行结尾指定为\n。
    When writing in text mode, the default is to convert occurrences of \n back to platform-specific line endings
    在text mode**写时,**默认会将\n 的出现转化回platform-specific line endings平台特定的每行末尾。
    This behind-the-scenes modification to file data is fine for text files, but will corrupt binary data like that in JPEG or EXE files. Be very careful to use binary mode when reading and writing such files.

    当处理file对象时,使用with关键字是非常好的习惯。因为在with下,file可以被properly closed after its suite finishes, even if an exception is raised at some point. Using with is also much shorter than writing equivalent try-finally blocks,同时使用with也比写 try-finally blocks更简短。

    with open('workfile') as f: ... read_data = f.read() f.closed True

    如果使用with关键字的话,你就必须调用 **f.close() **去关闭file对象并且立即释放被file占用的任何系统资源——immediately free up any system resources used by it. If you don’t explicitly close a file, Python’s garbage collector will eventually destroy the object and close the open file for you , but the file may stay open for a while. Another risk is that different Python implementations will do this clean-up at different times.

    一旦file object is closed, 无论是with statement或者是by calling f.close()的尝试to use the file object 都会自动失败will automatically fail.

    所以说,使用with语句不用费心file.close()的问题,强烈建议使用with open statement

    7.2.1. Methods of File Objects

    接下来的分析中我们都假定已经创建了一个名叫f的file。

    To read a file’s contents, call f.read(size), which reads some quantity of data and returns it as a string (in text mode) or bytes object (in binary mode). 可以通过调用f.read(size)来读取一个file的内容,f.read(size)在text mode下会读取一定数量的数据并且以string的方式返回,而在binary mode下则会以byte object的象时返回这部分数据。
    size is an optional numeric argument–size是一个可选的数值参数.
    When size is omitted or negative, the entire contents of the file will be read and returned; 当size参数被指定为负值或者不予指定的话,整个文件file的内容都会被read且按照前述方式返回。
    it’s your problem if the file is twice as large as your machine’s memory如果file是机器内存两倍大小,那么这个就是你自己的问题了。 Otherwise, at most size bytes are read and returned. 否则在大多数情况下,f.read(size)会尽可能地读取最多bytes并且返回。
    If the end of the file has been reached, f.read() will return an empty string (’’). 在到达文件file的末尾后,f.read()会返回一个空字符串’’。

    >>> f.read()
    'This is the entire file.\n'
    >>> f.read()
    ''
    

    f.readline() reads a single line from the file; 一个换行符 (\n) is left at the end of the string, and is only omitted on the last line of the file if the file doesn’t end in a newline. This makes the return value unambiguous不模糊; if f.readline() returns an empty string, the end of the file has been reached, while a blank line is represented by ‘\n’, a string containing only a single newline.
    f.readline()每次从file中读取一行,以一个string的形式返回并且在string的末尾加上一个换行符 \n,只有当文件不再在一个新行处结束时这个末尾换行符\n才会被省略。这一特点让返回值变得不模糊——在f.readline()函数返回一个空string时,意味着已经读到了file的末尾,而当空的一行用’\n’表示时,一个string只包含一个单独的新行。

    >>> f.readline()
    'This is the first line of the file.\n'
    >>> f.readline()
    'Second line of the file\n'
    >>> f.readline()
    ''
    

    For reading lines from a file, you can **loop over the file object.**可以对file对象进行循环, This is memory efficient, fast, and leads to simple code:

    >>> for line in f:
    ...     print(line, end='')
    ...
    This is the first line of the file.
    Second line of the file
    

    If you want to read all the lines of a file in a list you can also use list(f) or f.readlines().
    使用f.readlines()函数或者list(f)去读取all the lines of a file 到一个列表中去in a list
    f.write(string) writes the contents of string to the file, returning the number of characters written.

        >>> f.write('This is a test\n')
        15
    

    Other types of objects need to be converted – either to a string (in text mode) or a bytes object (in text mode) – before writing them:
    别的类型的对象在writing之前需要被转换成string 对象 (in text mode) 或者 a bytes对象 (in text mode) 。

    >>> value = ('the answer', 42)
    >>> s = str(value)  # convert the tuple to string
    >>> f.write(s)
    18
    

    f.tell() returns an integer giving the file object’s current position in the file represented as number of bytes from the beginning of the file when in binary mode and an opaque number when in text mode.
    f.tell()会返回一个整数,这个integer提供了该file object当前在该file中的位置信息,这个整数会被表示为number of bytes from the beginning of the file(在binary 模式下)或者被表示为一个an opaque number (在text模式下)。

    To change the file object’s position, use f.seek(offset, from_what).
    想要改变file对象的位置,可以使用 f.seek(offset, from_what)。
    The position is computed from adding offset to a reference point;
    该位置position通过在参考点基础上加一个偏移量offset得到。
    通过 from_what参数来选择the reference point参考点。
    参数from_what=0 意味着从the beginning of the file开始measure,
    参数from_what=1 意味着从the current file position开始measure,
    参数from_what=2意味着将the end of the file 作为参考点reference point.
    参数from_what可以忽略,但是默认值为0即使用file的开始位置作为参考点开始计量。

    >>> f = open('workfile', 'rb+')
    >>> f.write(b'0123456789abcdef')
    16
    >>> f.seek(5)      # Go to the 6th byte in the file
    5
    >>> f.read(1)
    b'5'
    >>> f.seek(-3, 2)  # Go to the 3rd byte before the end
    13
    >>> f.read(1)
    b'd'
    

    In text files (those opened without a b in the mode string), 那些通过mode string中没有b的方式打开的文件——即text files中,只允许相对于the beginning of the file的查找,唯一合法的偏移量值offset values是由f.tell()返回的值或者是0。其他的offset value会产生没有定义的行为。only seeks relative to the beginning of the file are allowed (the exception being seeking to the very file end with seek(0, 2)) and the only valid offset values are those returned from the f.tell(), or zero. Any other offset value produces undefined behaviour.

    File objects have some additional methods,File对象的别的方法,比如 satty() 和truncate() which are less frequently used; consult the Library Reference for a complete guide to file objects.

    增加内容:
    Reference Website: https://www.cnblogs.com/ymjyqsx/p/6554817.html
    Author: levi 编辑于 2019-02-24

    Python引入了with语句来自动帮我们调用close()方法:

    with open('/path/to/file', 'r') as f:
        print(f.read())
    

    这和前面的try … finally是一样的,但是代码更佳简洁,并且不必调用f.close()方法。

    调用read()会一次性读取文件的全部内容,如果文件有10G,内存就爆了,所以,要保险起见,可以反复调用read(size)方法,每次最多读取size个字节的内容。另外,调用**readline()可以每次读取一行内容,调用readlines()**一次读取所有内容并按行返回list。因此,要根据需要决定怎么调用。

    在这里插入图片描述
    如果文件很小,read()一次性读取最方便;
    如果不能确定文件大小,反复调用read(size)比较保险;
    如果是配置文件,调用readlines()最方便:

    for line in f.readlines():
        print(line.strip()) # 把末尾的'\n'删掉
    

    对于多个文件的读写,可以写成以下两种方式:

    with open('/home/xbwang/Desktop/output_measures.txt','r') as f:
        with open('/home/xbwang/Desktop/output_measures2.txt','r') as f1:
            with open('/home/xbwang/Desktop/output_output_bk.txt','r') as f2:
           ........
           ........
           ........
    
    with open('/home/xbwang/Desktop/output_measures.txt','r') as f:
    ........
    with open('/home/xbwang/Desktop/output_measures2.txt','r') as f1:
    ........
    with open('/home/xbwang/Desktop/output_output_bk.txt','r') as f2:
    ........
    
    展开全文
  • 注意matplotlib中画散点图的scatter函数的参数c的用法 c的值不可以是列向量 import numpy as np import matplotlib.pyplot as plt if __name__ == '__main__': # 1. 数据生成 N = 100 x = np.random.uniform(low...
  • R语言which函数使用

    万次阅读 2018-06-20 15:23:14
    搜索矩阵A和B相同行名时是哪一行,用which函数可以实现A是nxm的矩阵B是pxk的矩阵搜索B中行名和A中行名相同的行,行号记录在向量a中a&lt;-vector()for(i in 1:nrow(B)){a[i]&lt;-which(colnames(A)==colnames...
  • python 常用文件读写及with用法

    千次阅读 2018-07-30 13:53:00
     with用法稍后讨论,上面运行结果,那么我们深入到reader这个方法本身去看看究竟,python源代码如下: def reader(iterable, dialect='excel', *args, **kwargs): # real signature unknown; NOTE: ...
  • 对于不熟悉这种用法的读者来说,这无疑使人困扰,本文的目的就是给出这种语法的一个解释,并且给出几个例子。 在Python中,return self的作用为:(英语原文,笔者水平有限,暂不翻译) Returning self from a ...
  • JUnit高级用法之@RunWith

    千次阅读 2017-10-14 22:02:00
    * @deprecated Included for backwards compatibility with JUnit 4.4. Will be * removed in the next major release. Please use * {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}. *...
  • 关于oracle with table as 创建临时表的用法示例 1、with table as 相当于建个临时表(用于一个语句中某些中间结果放在临时表空间的SQL语句),Oracle 9i 新增WITH语法,可以将查询中的子查询命名,放到SELECT语句...
  • in which可以翻译成在……里面for which可以翻译成为了……目的on which可以翻译成在……的上面,或具体时间的某一天at which可以翻译成在……里面或在……上面这些介词的使用除了意思上的区别,具体是要以which...
  • tensorflow中python中with用法的理解

    千次阅读 2017-09-22 19:06:23
    出处:http://blog.csdn.net/u011534057/article/details/53082106 class tf.Session ...A class for running TensorFlow operations. ...A Session object encapsulates the environment in which Operatio
  • switch case语句的用法

    万次阅读 2019-10-31 16:26:41
    switch case语句的用法 我们首先来看一下switch case 语句的一般形式是怎样的 switch(表达式){ case 常量1 : 代码块; break; case 常量2: 代码块; ...
  • Java String startsWith()方法与示例

    千次阅读 2020-07-12 14:08:23
    字符串startsWith()方法 (String startsWith() Method) startsWith() method is a String class method, it is used to check whether a given string starts with specific character sequences or not. starts...
  • 本文翻译自Python的开发者指南PEP 492。...网上async with和async for的中文资料比较少,我把PEP 492中的官方陈述翻译一下。 异步上下文管理器”async with” 异步上下文管理器指的是在enter和exit方法处能够
  • compare的用法知识整理

    千次阅读 2021-05-23 09:21:48
    compare有对比的意思,那么你知道他具体应该怎么用吗,接下来小... 比较[ 过去式 compared 过去分词 compared 现在分词 comparing 第三人称单数 compares ]词组短语compare with 与…相比较compare notes 交换意见c...
  • Spring中@Transactional用法深度分析之一

    万次阅读 多人点赞 2015-03-27 22:40:46
    具体各个属性的用法和作用,将在本文的后面逐一进行讲解和说明。 2. 使用@Transactional的Spring配置  为了使用基于@Transactional的事务管理,需要在Spring中进行如下的配置: class="org....
  • show的用法和例句

    千次阅读 2021-05-23 11:48:40
    show的用法show的用法1:show的基本意思是“给…看”,可指有意或无意地将某物置于他人视野内,也可指将他人带到能看到该物的地方。show也可作“上演、展出”; “为…带路”,“带…到某处”解,引申还可表示“表现出”....
  • repartition和coalesce的用法

    千次阅读 2018-08-03 11:08:16
    * which can avoid performing a shuffle. */ def repartition (numPartitions: Int) (implicit ord: Ordering[T] = null) : RDD[T] = withScope { coalesce(numPartitions, shuffle = true) } 二、 ...
  • SQL 中 with as 用法(转)

    千次阅读 2011-12-21 09:51:44
    with sql1 as (select to_char(a) s_name from test_tempa), sql2 as (select to_char(b) s_name from test_tempb where not exists (select s_name from sql1 where rownum=1)) select * from sql1ITPUB个人空间...
  • c++switch的基本用法

    万次阅读 多人点赞 2017-07-30 15:08:38
    switch只能接受整型和字符型:整型:#include using namespace std;int main(void){ int a; while(true) { cin >> a; switch(a) { case 1: cout ; break;
  • 下面主要用例子说明用法(bash环境下测试)1.echo显示字符串普通字符串可以在echo后直接输入字符串,但这样当要输出某些字符如\时会有问题(这种写法的时候\是被当作继行符处理过滤掉的,要输出一个\必须打\\,跟c语言...
  • 【C#】switch的用法

    千次阅读 2019-03-07 09:45:16
    【switch是什么】 switch语句是一个控制语句,选择“开关部分”从候选列表中执行。 每个开关部分包含一个或者多个用例标签和含有一个或者多个语句的列表,, ...
  • show的用法及句型

    千次阅读 2021-05-23 11:49:38
    show的用法及句型2020-05-21 13:28:18文/钟诗贺show 表示使被看见,出示;把…拿给…看。to show one's papers,出示证件to show something to somebody把某物给某人看。还表示表露,露出:to show one's ...
  • Dan_Sake 总结const用法一文,《const T vs. T const》本文和原创译稿,本文讲得深入清楚,帮助清楚声明的规则,出自《嵌入式系统编程》,是非常经典的文献。
  • [最终答案]which指代的三种情况

    千次阅读 2019-09-21 04:15:23
    关于N, which的小结 which指代的三种情况: 目录 1、 紧邻修饰 2、 跳跃修饰 3、 特别情况 A and B, which 1、 紧邻修饰 一般情况下,“名词,which”中的which是就近修饰紧邻的名词的。这种例子多的...
  • Golang 之context用法

    千次阅读 2020-06-24 18:33:26
    使用示例3.1 WithCancel3.2 WithDeadline3.3 WithTimeout3.4 WithValue 1. context Golang 中的context 是Go语言在 golang1.7 发布时新增的标准包 目的是增强Golang开发中并发控制技术 简单来讲当一个服
  • systemd用法

    千次阅读 2018-01-09 16:00:25
     files, which are in turn inspired by Microsoft Windows  .ini  files. Unit files are loaded from two locations. From lowest to highest precedence they are: /usr/lib/systemd/system/ : units ...
  • apt apt 用法_apt命令–实用用法指南

    千次阅读 2020-07-20 10:34:52
    apt apt 用法This guide will walk you through everything you’d need to start using the apt command in Linux. Packages help in delivering or installing any application on a Linux running system. A ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 51,423
精华内容 20,569
关键字:

which的用法 with