English 中文(简体)
甲骨质素使用器
原标题:Drop user cascade in Oracle
  • 时间:2010-11-04 12:20:02
  •  标签:
  • sql
  • oracle

我需要能够将特定用户(可能拥有积极会议)从批次中删除,而不进行任何用户互动<>。 我不关心积极的会议,希望它们退席。 对Microsoft Koui来说,同样的任务只有一个线:

osql -E -S localhost -b -Q "use master if ((select name from sysdatabases where name= %DB% ) is not null) begin alter database [%DB%] set single_user with rollback immediate drop database [%DB%] end"

如何为Oracle(Windows 10g XE)做?

我目前的争论是:

sqlplus sys/*** as SYSDBA  @delete1.sql >delete.log
sqlplus sys/***@XE as SYSDBA  @delete2.sql >>delete.log

删除1.sql:

startup force;
exit;

and delete2.sql:

drop user MYUSER cascade;
exit;

这与多指标类集调查解决办法的分部分二相比,这是很费时的。

最佳回答

It should work if you use the following script (here named drop_user_with_active_sessions.sql):

set verify off

begin

  for s in (
    select 
      sid, serial#
    from
      v$session
    where 
      username =  &1 
  ) loop

    execute immediate 
        alter system kill session     || 
        s.sid     ||  ,  ||
        s.serial# ||     immediate ;

  end loop;

  execute immediate  drop user &1 ;

end;
/

exit

以及使用

sqlplus username/password@instance @c:path	odrop_user_with_active_session.sql MYUSER
问题回答

除了上文提到的“死灰复燃的系统杀人”之外,我还想用诸如:

execute immediate  ALTER SYSTEM DISCONNECT SESSION     ||
    to_char(s.sid) ||  ,   || to_char(s.serial#) ||     IMMEDIATE 

从一个数据库平台上进行构造,假定我能在不同的平台上做同样的事情,这是非常坏的想法。 例如。 甲骨质已经建立了OR REPLACE程序。 生活津贴非常简单。 MSSS, 您可以在Oracle使用DDL的一张“模版”表格。 虽然放弃新环境的使用者可能是管理支助服务的最简单办法,但或许可以采取更加以甲骨质为中心的方法来完成同样的事情。 要求帮助如何完成一项任务,而不是为什么你不工作,这是非常好的想法。

首先,正在测试的仪器是否是DDL? 表格和其他物体?

如果只改动数据,他们就宁愿工作,那么,你为什么必须重新计算所有物体。 你们刚刚需要把数据回头来。

您是否对闪back数据库进行了研究? 你们应该能够创造一个恢复点,......你们想要做什么,然后及时将数据库重新启用。





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...