1.启动、关闭Oracle数据库

(1).Oracle数据库启动
1).启动阶段

shutdown->nomount->mount->open
在这里插入图片描述

2).启动指令
sqlplus / as sysdba
startup
startup force :强制启动
(2).Oracle数据库关闭
1).关闭模式

中止(abort)、立即(immediate)、正常(normal)、事务性(transactional)

中止立即正常事务性
允许新连接nononono
等待当前会话结束nonoyesno
等待当前交易结束nonoyesyes
强制检查点和关闭文件noyesyesyes
2).关闭指令
shutdown abort:中止
shutdown immediate:立即
shutdown normal:正常
shutdown transactional:事务性

2.通过pfile、spfile启动并设置初始化参数

(1).通过spfile启动
1).通过spfile启动

数据库实例默认通过spfile启动

//查看数据库是否通过spfile自动,若有值代表通过spfile启动
show parameter spfile

//默认spfile存放位置
$ORACLE_HOME/dbs/spfile[orcl实例名].ora
/u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileorcl.ora
2).创建spfile

系统会在上述目录下创建默认spfile

//通过pfile创建
create spfile='/temp/spfileorcl.ora' from pfile;

//通过内存创建(不推荐参数会很多)
create spfile='/temp/spfileorcl.ora' from memory;

(2).通过pfile启动
1).创建pfile
//通过spfile
create pfile='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/pfileorcl.ora' from spfile;

//通过内存创建(不推荐参数会很多)
create pfile='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/pfileorcl.ora' from memory;
2).通过pfile启动
 startup pfile='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/pfileorcl.ora';
(3).官网查询初始化参数

https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/index.html

3.启动、关闭pdb

(1).启动、关闭pdb指令
  • 不设置session启动、关闭
//启动
alter pluggable database ORCLPDB3 open;
alter pluggable database ORCLPDB1 open;
alter pluggable database all open; //开启全部pdb
//停止
alter pluggable database ORCLPDB3 close;
alter pluggable database ORCLPDB1 close;
alter pluggable database all close; //关闭全部pdb
  • 设置指定pdb的session启动、关闭
//设置pdb的session
alter session set container=ORCLPDB1;
//取消设置(切换到CDB)
alter session set container = CDB$ROOT;


//只能操作ORCLPDB1
alter pluggable database open;
alter pluggable database close;
(2).保留pdb状态
  • 单个pdb
//保留pdb状态
 alter pluggable database  orclpdb1 save state;
 
//取消状态
 alter pluggable database  orclpdb1 discard state;
  • 所有pdb
//保留pdb状态
 alter pluggable database all save state;
 
//取消状态
 alter pluggable database all discard state;

更多推荐