删除数据库 - with DROP DATABASE Statement

Oracle 10g 增加了drop database
命令,这样我们删除数据库会方便很多。 不过DROP DATABASE还是有一定的限制条件的:

一些错误

1.ORA-01586: database must be mounted EXCLUSIVE and not open for this
operation

SQL> conn / as sysdba
Connected.
SQL> drop
database;
drop database
*
ERROR at line 1:
ORA-01586: database must
be mounted EXCLUSIVE and not open for this operation

2.
ORA-12719: operation requires database is in RESTRICTED mode

SQL>
alter database close;
Database altered.
SQL> drop database;
drop
database
*
ERROR at line 1:
ORA-12719: operation requires database is
in RESTRICTED mode

解决办法

SQL> alter database close;
SQL> alter system enable restricted
session;
System altered.

SQL> drop database;
Database
dropped.

或者正确的命令

SQL>startup
mount

SQL>alter
system enable restricted session;

SQL>DROP
database;

限制条件(sql reference 原文):
drop database

  • You must have the SYSDBA system privilege to issue this statement.

  • The databasemust be mounted in exclusive and restricted mode

  • it must be closed.

Restricted mode:
The RESTRICTED SESSION clause lets
you restrict logon to Oracle.
You can use this clause regardless of whether
your instance has the database dismounted or mounted, open or
closed.

Restricting Session Logons:

Example You may want to restrict logons if you are performing application
maintenance and you want only application developers with RESTRICTED SESSION
system privilege to log on.

To restrict logons, issue the following statement:
ALTER
SYSTEM ENABLE RESTRICTED SESSION;

You can then terminate any
existing sessions using the KILL SESSION clause of the ALTER SYSTEM
statement.
After performing maintenance on your application, issue the
following statement to allow any user with CREATE SESSION system privilege to
log on:ALTER SYSTEM DISABLE
RESTRICTED SESSION;

RESTRICTED
SESSION,允许你以约束的方式登录数据库。你可以使用这个子句无论数据库是否挂载或者是否打开。

总结-有四点:

1、拥有SYSDBA 权限。
2、数据以独享的方式被挂载, Oracle
启动存在两种方式:独占和共享,独占启动的选项是exclusive,表示只允许一个例程使用该数据。共享启动的参数是shared,表示允许多个例程并行使用该数据库。  
 
3、以RESTRICTED SESSION 登录数据库。
4、数据库处于关闭状态。

DROP
DATABASE该命令的作用:

  • When you issue this statement, Oracle Database drops the database and
    deletes all control files and datafiles listed in the control file.

  • If the database used a serverparameter file (spfile), it is also
    deleted.

  • Archived logs and backups are not removed, but you can use Recovery
    Manager (RMAN) to remove them.

  • If the database is on raw disks, this statement does not delete the actual
    raw disk special files.

删除数据库 - with DROP DATABASE Statement,布布扣,bubuko.com

时间: 2024-08-05 02:22:19

删除数据库 - with DROP DATABASE Statement的相关文章

创建数据库 - with CREATE DATABASE STATEMENT

1. Set SIDin bashORACLE_SID=ocmexport ORACLE_SID2. Set Env VarsORACLE_SID and ORACLE_HOME3. Choose a Database Administrator Authentication Methodpassword fileOS auth4. Create Init Parameter File$ORACLE_HOME/dbs/initocm.ora6. Connect to the InstancePa

create database ,drop database ,show Databases,use 数据库 ,怎么使用?

1)库本身的基本操作:(视频下载) (全部书籍) 1)创建数据库:create database 数据库名字;2)删除数据库:drop database 数据库名字;3)查看数据库:show Databases; 显示由Server管理的数据库4)使用数据库,之后的操作就针对此数据库了:use 数据库名字 详情请见:http://www.mark-to-win.com/index.html?content=Mydb/DBUrl.html&chapter=Mydb/DBIntroduction_w

Mysql新建数据库、删除数据库

新建数据库 create database db_name; //db_name为新建数据库的名字 删除数据库: drop database db_name; drop database if exists db_name; //判断db存在之后在删除,否则忽略,不会报错 新建数据库并设置编码环境: create database db_name charset utf8;

php 创建删除数据库

<?php $dbhost = 'localhost:3306'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully<br />'; //删除数据库 /*$sql = 'DROP DATABASE

数据库操作(DataBase)

1.连接数据库 win+R > cmd > mysql -h localhost -uroot -p 2.数据库的操作 创建数据库:create database 数据库名称; 删除数据库:drop database 数据库名称; 显示数据库:show databases; 使用数据库:use 数据库名称; 3.表操作 显示所有表:show tables; 删除表:drop table 表名: 创建表:create table 表名(id int(11) unsigned not null a

数据库部分---添加/删除数据库,添加/删除表格,往数据库添加数据;

一: 1.创建数据库 create database test2; 2.删除数据库: drop database test2; 3.创建表: create table test ( code varchar(20) , name varchar(20)                 #varchar是字符串类型,需要加长度(20),code和name都是创建的列的名字,一列写完要写逗号,最后一列不加逗号. );                                         #

mysql数据库的基本操作:创建数据库、查看数据库、修改数据库、删除数据库

本节相关: 创建数据库,查看数据库,修改数据库,删除数据库 首发时间:2018-02-13 20:47 创建数据库  : 语法  : create database 数据库名字[库选项]; 库选项说明  : 库选项是可选项,可以不写 库选项有两项:字符集和校对集. 库选项的字符集是数据库识别或存储数据使用的字符集.常用字符集有utf8和gbk; 库选项的校对集是数据库校对数据时使用的校对集[校对数据时依据校对集的规则来校对,比如有些校对集忽略大小写]. 但凡是创建数据库时不指定库选项的,都将使用

ORACLE手工删除数据库

很多人习惯用ORACLE的DBCA工具创建.删除数据库,这里总结一下手工删除数据库实验的步骤,文中大量参考了乐沙弥的手动删除ORACLE数据库这篇博客的内容,当然还有Oracle官方相关文档.此处实验环境为Oracle Linux Server release 5.7,数据库版本为10.2.0.5.0 Step 1: .获得控制文件.数据文件,日志文件等相关信息 获取这些信息,一方面是为了后面的建库做参考,另外一个是为了验证后面一些操作,如果这些都没有必要,其实是可以可以跳过这一步的. SQL>

MySQL Drop Database之后的恢复测试

工具介绍 工具的名字叫做:  undrop-for-innodb 代码地址: https://github.com/twindb/undrop-for-innodb 官方文档: https://recovery.twindb.com/ 介绍工具的一篇ppt  http://www.slideshare.net/akuzminsky/undrop-for-innodb 当MySQL 执行 Drop Table或者 Drop Database 的时候,InnoDB并没有删除数据,数据的Page还在磁