美文网首页
数据库操作sql

数据库操作sql

作者: 阔阔飞翔 | 来源:发表于2019-06-25 11:17 被阅读0次

    一、新建表空间

    1、创建表空间名称

    create tablespace ZDRY datafile 'ZDRY.dbf' SIZE 50m;

    2、创建用户密码,用户名zdry,密码123456

    create user zdry identified by 123456  default tablespace ZDRY

    3、给用户授权

    grant connect,resource,dba to zdry;

    二、批量插入(insert 和select)

    INSERT INTO t_zdry ( ZJ, RYBH, XM, XMPY, XB ) SELECT

    sys_guid () zj,

    rybh,

    xm,

    '' xmpy,

    '' xb

    FROM

    export_table;

    三、批量修改(update和select)

    UPDATE t_zdry a

    SET a.jtgjlxcphm =

      (SELECT b.lxhm FROM export_table33 b WHERE b.glbh=a.rybh AND b.gllx = '08'

      )

    WHERE EXISTS

      (SELECT 1 FROM export_table33 b WHERE b.glbh=a.rybh AND b.gllx = '08'

      );

    四、行转列

    SELECT MAX(t.gllx) gllx,

      t.glbh, WMSYS.wm_concat(t.xxlx1 || ':' ||t.xxqz1) lxhm

    FROM

      (SELECT DISTINCT gllx, xxlx1, xxqz1 ,glbh

      FROM ythgkpt.t_fxk_xxkz

      WHERE GLBH IN

        (SELECT rybh FROM ythgkpt.vm_jwzyddc_ryxx t)

      ) t

    GROUP BY t.glbh;

    相关文章

      网友评论

          本文标题:数据库操作sql

          本文链接:https://www.haomeiwen.com/subject/dtctcctx.html