zoukankan      html  css  js  c++  java
  • oracle基本操作符/运算符/操作语言

    racle中的操作符

    算术操作符:

    无论是在sqlserver,或者是java中,每种语言它都有算术操作符,大同小异。
    Oracle中算术操作符(+)(-)(*)(/) 值得注意的是:/ 在oracle中就相当于显示中的除法 5/2 = 2.5

    比较操作符:

        其中等号可以换成其他运算符:(后面为该操作符的单条件查询样例)

      
        != 不等于 select empno,ename,job from scott.emp where job!='manager'

        ^= 不等于 select empno,ename,job from scott.emp where job^='manager'

        <>不等于  select empno,ename,job from scott.emp where job<>'manager'

        <小于  select sal from scott.emp where sal<1000

        >大于 select sal from scott.emp where sal>1000

        <=小于等于 select sal from scott.emp where sal<=1000

        >=大于等于  select sal from scott.emp where sal>=1000

        in 在列表  select sal from scott.emp where sal in(1000,2000)
        时间的查询可以使用in 例如  select * from student where time in (’06-3月-09’,’08-5月-09’); 

        not in 不在列表 select sal from scott.emp where sal not in(1000,2000)

        between...and 介于..与..间 

                       select sal from scott.emp where sal  between 1000 and 2000


        not between...and 不介于..与..之间  

                       select sal from scott.emp where sal not between 1000 and 2000

        like 模式匹配  select ename from scott.emp where ename like 'M%' (%表示任意长度的长度串)
                       select ename from scott.emp where ename like 'M_' (_表示一个任意的字符)


        is null 是否为空  select ename from scott.emp where ename is null

        is not null 不为空 select ename from scott.emp where ename is not null

    逻辑操作符:

        or(或)  select ename from scott.emp where ename='joke' or ename='jacky'

        and(与) select ename from scott.emp where ename='and' or ename='jacky'

        not(非) select ename from scott.emp where not ename='and' or ename='jacky'
     
    集合操作符:

        union(并集)       union连接两句sql语句, 两句sql语句的和 去掉重复的记录。

                            (select deptno from scott.emp) union (select deptno from scott.dept)

        union all(并集)   接两句sql语句,两句sql语句的和不用去掉重复的记录。 

                            (select deptno from scott.emp) union all (select deptno from scott.dept)

        intersect (交集)  Intersect连接两句sql语句 取查询出来的两个集合的 共同部分。

                            (select deptno from scott.emp) intersect (select deptno from scott.dept) 

        minus (补集)      Minus 连接两句sql 语句,取查询出来的两个集合的差。
                            (select deptno from scott.emp) minus (select deptno from scott.dept)

    连接操作符: (||) 用来连接连个字段,或者将多个字符串连接起来。

    操作符的优先级别:算术》连接》比较》逻辑(not and or)

    Oracle中的数据类型

    数据类型主要有:字符 数值 日期 大对象LOB row/long row  

    字符类型:(varchar  varchar2  long)
        Varchar:长度不可变,最大2000个字节
        Varchar2:长度可变,最大4000个字节
        Long:长度可变  最大2G

    数值类型:oracle中对int double float进行整合成  number类型。
        Number[p,s]:p表示精度,s表示小数位数。

    日期类型:(date)(timestamp)
        Date类型存储日期类型,包括 年月日时分秒。
        Timestamp类型存储日期类型,包括更加精确的信息,包括地区信息,年月日时分秒。毫 秒……。

        DATE数据类型的主要问题是它粒度不能足够区别出两个事件哪个先发生。ORACLE已经在DATE数据类型上扩展出来了TIMESTAMP数据类型,它包括了所有DATE数据类型的年月日时分秒的信息,而且包括了小数秒的信息。如果你想把DATE类型转换成TIMESTAMP类型,就使用CAST函数。 
      eg. SQL> SELECT CAST(date1 AS TIMESTAMP) "Date" FROM t;

    Raw类型:存储二进制数据

    Longraw类型:存储可变长度的二进制数据。最大可以为2G。

    Oracle中的伪列
    (rowid)(rownum)伪列是向数据表中插入数据时系统会自动向每条数据添加两列数据字段。

    Rowid 每条记录的实际存储地址,即使记录重复这个字段也不会出现重复。
    Rownum是 查询出数据后为每条记录添加的字段,他并不是真是存在,而是相当于视图一样查询出来后自动添加的一个行号。当运行select rowed,rownum from 表名;就可以查看这几数据。

    Oracle中的sql语句Sql语句是通用的数据库语言
    Sql命令包括 (DDL)(DCL)(DML)(TCL)
    DDL:数据定义语言  包括 Create语句,drop语句,alter语句。
    DCL: 数据控制语言  包括 grant语句。 Revoke语句
    DML:数据控制语言  包括 增,删,改,查语句。
    TCL:事物控制语言  包括  commit,rollback,savepoint


  • 相关阅读:
    python并发编程之多进程
    python并发编程之多进程理论部分
    Python GIL(Global Interpreter Lock)
    python并发编程之多线程
    前端基础之CSS
    前端知识之HTML内容
    Python杂货铺-(1)os模块在python中执行shell命令
    Hive学习小记-(17)inline(array(struct))与explode
    Hive学习小记-(16)hive加载解析json文件
    Hive学习小记-(15)transform函数
  • 原文地址:https://www.cnblogs.com/wdas-87895/p/6259708.html
Copyright © 2011-2022 走看看