如果只是删除数据库而无需删除数据库软件,可通过如下两种方式实现。
注意:工作中删库需谨慎哦!
方法一、DBCA 删除数据库
如下查询可看出当前存在数据库:
[root@ocpstudy ~]# su - oracle
Last login: Sat Mar 16 18:08:21 CST 2024 on pts/5
[oracle@ocpstudy ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 16 22:19:06 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SYS@orcl(CDB$ROOT)> select status from v$instance;
STATUS
------------
OPEN
SYS@orcl(CDB$ROOT)>
在oracle用户下执行dbca调出图形界面:
$ dbca
1.选择“delete database” 并点击Next进入下一步
2.选择要删除的数据库(这里选择orcl)并点击Next进入下一步
3.直接点击Next进入下一步
4.如果确认要删除orcl数据库,点击Next进入下一步。如果反悔不想删了,可以点击Cancel取消。
5.这里还有一次反悔的机会,如果不想删了就点击No取消。如果确认要删除orcl数据库,则点击Yes开始删除。
6.正在删除
7.删除完成,点击Close关闭窗口即可。
这时再次执行如下查询会发现数据库已经不存在了:
[oracle@ocpstudy ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 16 22:34:07 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
方法二、Drop database 删除数据库
我们用第二种方式删除另一个数据库oradb
1.切换数据库实例
[oracle@ocpstudy ~]$ ps -ef|grep smon
oracle 31101 1 0 02:24 ? 00:00:01 ora_smon_oradb
oracle 111569 110069 0 22:36 pts/5 00:00:00 grep --color=auto smon
[oracle@ocpstudy ~]$ export ORACLE_SID=oradb
2.sqlplus连接数据库
[oracle@ocpstudy ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 16 22:37:40 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SYS@oradb(oradb)> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
ORADB READ WRITE
3.使用drop database删除数据库
SYS@oradb(oradb)> drop database;
drop database
*
ERROR at line 1:
ORA-01586: database must be mounted EXCLUSIVE and not open for this operation
SYS@oradb(oradb)>
4.将数据库调整到受限模式后再次删除
SYS@oradb(oradb)> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@oradb(oradb)> startup restrict force mount
ORACLE instance started.
Total System Global Area 855635584 bytes
Fixed Size 8902272 bytes
Variable Size 243269632 bytes
Database Buffers 599785472 bytes
Redo Buffers 3678208 bytes
Database mounted.
SYS@oradb(oradb)> drop database;
Database dropped.
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
@(oradb)>
以上是删除数据库的两种方式,建议使用第一种方式。
标签:教程,删除,0.0,数据库,SYS,oradb,oracle From: https://blog.csdn.net/Ruishine/article/details/136771515