title: Drop user cascade in Oracle
body: <p>I need to be able to drop a specific user (which may have active sessions) from the batch <em>without any user interaction</em>. I don't care about active sessions and want them to be dropped and rolled back. For Microsoft SQL i would do similar task with a single line:</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>How do i do it for Oracle (10g XE on Windows)?</p>
  
  <p>My current batch is:</p>
  
  <pre><code>sqlplus sys/*** as SYSDBA  @delete1.sql &gt;delete.log
  sqlplus sys/***@XE as SYSDBA  @delete2.sql &gt;&gt;delete.log
  </code></pre>
  
  <p>where delete1.sql:</p>
  
  <pre><code>startup force;
  exit;
  </code></pre>
  
  <p>and delete2.sql:</p>
  
  <pre><code>drop user MYUSER cascade;
  exit;
  </code></pre>
  
  <p>This is ugly as hell and takes too long comparing to the split second of MSSQL solution.</p>