Get the App
SLTechnology News&Howtos  ›  Database  › 

Unplug and delete Oracle12c_PDB

Shulou Source: shulou.com Published: 2022-06-01 07:12:58 10月15日 Update

Here is a brief description of how to unplug PDB, delete PDB, and insert PDB:

1 、 unplug PDB

View PDB information:

SQL > select name,open_mode from v$pdbs

NAME OPEN_MODE

PDB$SEED READ ONLY

PDB_1 READ WRITE

PDB_2 READ WRITE

PDB_3 READ WRITE

PDB_4 READ WRITE

SQL > show con_name

CON_NAME

-

CDB$ROOT

Unplug the PDB_4 (must be connected to the CDB$ROOT):

First turn off PDB_4

SQL > alter pluggable database pdb_4 close immediate

Pluggable database altered.

Then you can unplug.

SQL > alter pluggable database pdb_4 unplug into'/ home/oracle/unplugged_pdbs/pdb_4.xml'

Pluggable database altered.

The XML file contains information such as the location of each data file, as well as initialization parameters.

2 、 drop PDB

You can delete the data file when you close and unplug the PDB, and delete the data file together:

You also need to connect to the CDB$ROOT container and execute the following statement:

SQL > drop pluggable database pdb_4 keep datafiles

Pluggable database dropped.

SQL > select name,open_mode from v$pdbs

NAME OPEN_MODE

PDB$SEED READ ONLY

PDB_1 READ WRITE

PDB_2 READ WRITE

PDB_3 READ WRITE

Keep datafiles is used here to retain the data files of PDB_4. Alternatively, you can use inluding datafiles to completely delete PDB's data files.

3 、 plug an unplugged PDB

Plug PDB_4:

SQL > create pluggable database pdb_4_replug using'/ home/oracle/unplugged_pdbs/pdb_4.xml' nocopy tempfile reuse

Pluggable database created.

SQL > select name from v$pdbs

NAME

-

PDB$SEED

PDB_1

PDB_2

PDB_3

PDB_4_REPLUG

SQL > select name,open_mode from v$pdbs

NAME OPEN_MODE

PDB$SEED READ ONLY

PDB_1 READ WRITE

PDB_2 READ WRITE

PDB_3 READ WRITE

PDB_4_REPLUG MOUNTED

In the above create pluggable database statement, because the data files are all in the location specified by the xml file, and the original location is still used as the new

The location where the data file of the pdb is stored, so there are no other clauses.

Another plug PDB statement may also be as follows:

CREATE PLUGGABLE DATABASE pdbname

USING'/ location/filename.xml'

SOURCE_FILE_NAME_CONVERT= ('/ location1/','/location2/')

MOVE

FILE_NAME_CONVERT= ('/ location2/','/location3/')

PATH_PREFIX='/location3/'

STORAGE (MAXSIZE 2G MAX_SHARED_TEMP_SIZE 100m)

Here the xml file indicates that the data file is in / location1/, but in fact the data file is in / location2/, and eventually we want to put the data file

Put in / location3/

Tags: File data location statement information middle finger parameter clause actual actually container method package storage Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux Shulou Tech Info macOS OPPO Reno