• oracle(3)


    存储过程:
    CREATE OR REPLACE PROCEDURE PROC_ABC
    (
    currency  IN NUMBER,
    aysdate   IN DATE,
    money     OUT number
    ) AS
    BEGIN
    dbms_output.put_line('ok');
    select 1 into money from dual;
    END;
    declare a number(21,6);
    begin
    PROC_ABC(1,sysdate,a);
    dbms_output.put_line(a);
    end;
    
    -- 注意:进出参数不能在存储过程中确定值范围
    create or replace procedure abc
    as
    begin
      dbms_output.put_line('ok');
    end;
    exec abc();

    下面说一下如何删除用户以及表空间。

    对于单个user和tablespace 来说, 可以使用如下命令来完成。

     步骤一:  删除user

    drop user drp  cascade

    说明: 删除了user,只是删除了该user下的schema objects,是不会删除相应的tablespace的。

    步骤二: 删除tablespace

    DROP TABLESPACE ts_drp INCLUDING CONTENTS AND DATAFILES;

    删除表空间分为以下几种情况。

    删除空的表空间,但是不包含物理文件
    drop tablespace tablespace_name;
    删除非空表空间,但是不包含物理文件
    drop tablespace tablespace_name including contents;
    删除空表空间,包含物理文件
    drop tablespace tablespace_name including datafiles;
    删除非空表空间,包含物理文件
    drop tablespace tablespace_name including contents and datafiles;
    如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
    drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;
    查询及删除重复记录的SQL语句

    DELETE from clb_distributor where (code) IN ( SELECT code FROM clb_distributor GROUP BY code HAVING COUNT(code) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM clb_distributor GROUP BY code HAVING COUNT(*) > 1);
    DELETE from clb_distributor_area where (distributor_code) IN ( SELECT distributor_code FROM clb_distributor_area GROUP BY distributor_code HAVING COUNT(distributor_code) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM clb_distributor_area GROUP BY distributor_code HAVING COUNT(*) > 1);


    1、查找表中多余的重复记录,重复记录是根据单个字段(Id)来判断

    select * from 表 where Id in (select Id from 表 group byId having count(Id) > 1)

    2、删除表中多余的重复记录,重复记录是根据单个字段(Id)来判断,只留有rowid最小的记录

    DELETE from 表 WHERE (id) IN ( SELECT id FROM 表 GROUP BY id HAVING COUNT(id) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM 表 GROUP BY id HAVING COUNT(*) > 1);

    3、查找表中多余的重复记录(多个字段)

    select * from 表 a where (a.Id,a.seq) in(select Id,seq from 表 group by Id,seq having count(*) > 1)

    4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录

    delete from 表 a where (a.Id,a.seq) in (select Id,seq from 表 group by Id,seq having count(*) > 1) and rowid not in (select min(rowid) from 表 group by Id,seq having count(*)>1)

    5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录

    select * from 表 a where (a.Id,a.seq) in (select Id,seq from 表 group by Id,seq having count(*) > 1) and rowid not in (select min(rowid) from 表 group by Id,seq having count(*)>1)

    ///////////有时候手动停止未提交的事务 导致的锁表

    elect sess.sid,
    sess.serial#,
    lo.oracle_username,
    lo.os_user_name,
    ao.object_name,
    lo.locked_mode
    from v$locked_object lo, dba_objects ao, v$session sess
    where ao.object_id = lo.object_id
    and lo.session_id = sess.sid;

    --杀掉会话
    alter system kill session 'sid,serial#';

    select username,serial#, sid from v$session;  ---查询用户会话

    alter system kill session 'serial#, sid ';---删除相关用户会话
     
     
  • 相关阅读:
    Github Actions 中 Service Container 的使用
    EFCore 5 新特性 SaveChangesInterceptor
    使用 Xunit.DependencyInjection 改造测试项目
    WeihanLi.Npoi 1.11.0/1.12.0 Release Notes
    新版本 swagger 组件中 Servers 的 坑
    JDBC 规范中文版 4.2- 第五章 类和接口
    JDBC 规范中文版 4.2 -第四章 概览
    JDBC 规范中文版 4.2 -第三章 新特性
    JDBC 规范中文版 4.2 -第二章 目标
    Serve static assets with an efficient cache policy
  • 原文地址:https://www.cnblogs.com/lifusen/p/8072428.html
Copyright © 2020-2023  润新知