数据库
首页 > 数据库> > 关于Orcal数据库常用语句

关于Orcal数据库常用语句

作者:互联网

ORCAL中常见语句(个人工作中用的比较多的):

      select * from T_test order by Uplinetime desc nulls last;

      update TH_YW_TS set PROB_TYPE=replace(PROB_TYPE,'(1)','')

      SELECT NVL(MAX(ID), 0)+1 as id FROM TH_DATA_SOURCES

      <selectKey resultType="java.lang.Integer" order="BEFORE" keyProperty="id">
        select TH_SYS_DICT_ID_SEQ.Nextval as id from DUAL
      </selectKey> 后面是insert语句

      TO_CHAR(r.REG_TIME / (1000 * 60 * 60 * 24) + TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') as regTimeToChar

    with tablea as (select sum(NUM_ROWS) as dataCount from table_name),
      tableb as (select name from tables) ,
      tablec as (select count(1) as dataSource from TH_SYS_DATA_TYPE),
      tabled as ( select count(1) as dataFill from TH_DATA_INPUT_LOG where type = 'write')
      select * from tablea,tableb,tablec,tabled
      查询出不同表中的字段,综合为一句sql语句

    (case when a.STATUS='live' then '使用' when a.STATUS='dead' then '冻结' else '' end) as status (判断是null使用 is null不能使用==null)

      insert into TH_DATA_EXCEL_INPUT_FIELDS(ID, INFOID, EXCELNAME)
      select ROLE_CONTROLLER_ACTION_SEQ.Nextval as id, infoId, excelName
      from (
        <foreach collection="list" item="item" index="index" separator="union all">
          select '${item.infoid}' as infoId,
        '${item.excelname}' as excelName
        from dual
        </foreach>
        )

        &lt;= mabatis中的小于号

      select * from th_data_keyword where rownum >  #{from,jdbcType=DECIMAL}  and rownum <= #{to,jdbcType=DECIMAL}
      order by name asc,id desc(多个字段排序都要加上asc或者desc否在按照默认升序)

      SELECT * FROM th_yw_operation_log a where
          TO_CHAR(a.CREATETIME/(1000*60*60*24) +TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD')=
          TO_CHAR(1565170234000/(1000*60*60*24) +TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD')

    select count(*) from th_sys_data_type where NAME = #{name}
      <if test="id!=null and id !=''">
        and id <>  (#{id})

         或者

        and id !=  (#{id})
      </if>

    select * from ( select * from TH_YW_ZLHT where use_for = #{condition})
      <where>
        <if test="startTime!=null and endTime!=null and startTime!='' and endTime!=''">
             and (BILLING_CYCLE >= #{startTime} AND BILLING_CYCLE <= #{endTime}) OR
              (BILLING_CYCLE <= #{startTime} AND BILLING_CYCLE_END >= #{endTime}) OR
              (BILLING_CYCLE_END >= #{startTime} AND BILLING_CYCLE_END <= #{endTime})
        </if>
        <if test="startTime!=null and endTime == null " >
            and #{startTime} BETWEEN BILLING_CYCLE and BILLING_CYCLE_END
        </if>
        <if test=" endTime !=null and startTime==null" >
            and #{endTime} BETWEEN BILLING_CYCLE and BILLING_CYCLE_END
        </if>
      </where>

    select SUBSTR(time,1,10) from ( select to_char(trunc(sysdate + rownum-31,'dd'),'yyyy-mm-dd') time from dual connect by rownum <= 31 )

      

    <selectKey resultType="java.lang.Integer" order="BEFORE" keyProperty="id">
      select TH_SYS_TOKEN_SEQ.Nextval as id from DUAL
    </selectKey>

      insert into th_sys_controller_action
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
              id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
          <if test="id != null">
            #{id,jdbcType=INTEGER},
          </if>
        </trim>


        update th_sys_controller_action
          <set>
            <if test="controller != null">
              controller = #{controller,jdbcType=VARCHAR},
            </if>
          </set>

      update TH_CHART_DOM set DATA_URL = replace(DATA_URL,'http://192.168.0.13','http://192.168.0.51')

      进入 E:\app\A\product\11.2.0\dbhome_1\BIN 下打开cmd命令
    导出数据库
    exp.exe HSBIGDATA2/th2019@192.168.0.243/ORCL file=E:\export\HSBIGDATA2_0806.dmp log=E:\export\HSBIGDATA2_0806.log OWNER=HSBIGDATA2 rows=y indexes=n compress=n buffer=65536 feedback=100000
    导入数据库
    imp.exe HSBIGDATA2/th2019@192.168.0.243/ORCL file=D:\user.dmp fromuser=HSBIGDATA2 touser=HSBIGDATA2 rows=y commit=y feedback=10000 buffer=10240000

 

以上是个人在遇到orcal中比较常用的语句,要是有更多的语句可以交流留言

标签:语句,BILLING,数据库,TH,Orcal,id,select,CYCLE
来源: https://www.cnblogs.com/lxp-java/p/11316759.html