Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Oracle 12c uses SQL*Plus to create and delete application containers

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how Oracle 12c uses SQL*Plus to create and delete application containers, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!

You can create an application container in different ways, such as using CDB seed, cloning an existing PDB or Non-CDB, inserting a pulled PDB, or removing the application container from the CDB.

Create an application container

You can use the create pluggable database statement to create an application container in CDB. Specify the as application container clause when the create pluggable database statement is executed to create a new application container. The application container consists of an application root and a set of application PDB used to store one or more application data. The application PDB can be attached to the application root, and you can choose to quickly create the application seed and simply create a new application PDB. Application PDB and application root can share application public objects.

There are three types of application public objects:

. Metadata link application public objects store metadata for specific objects, such as tables. So containers can share application common objects with the same structure and no same data.

. Data link application public objects are defined only once in the application root and read-only objects are shared in the context of the application PDB.

. The extended data link application public object stores shared data in the application root but also allows the application PDB to add data to the object. The added data is local and is unique to each application PDB.

You can create an application container by executing the creatae pluggable database as application container clause. You can also use the following techniques to create an application container:

. Use CDB seed

. Clone an existing PDB or Non-CDB

. Migrate PDB

. Insert the unplugged PDB

The application container is created when the current container is the root of CDB and the as application container clause is specified when the create pluggable database statement is executed.

Migrate an existing application to an application container

You can create an application container by using an existing PDB. Additional tasks must be completed when migrating an existing application into an application container. The PDB to be attached must contain the application database objects, contain their data, and must perform the procedures in the dbms_pdb for the relevant database objects accessed by the application. When the application public user, role, or profiles is stored in the application root, the dbms_pdb package must be executed on the database objects associated with the application. After the application is migrated to an application container, the application PDB can be created in the application container, and the existing PDB can be used to create the application PDB.

Preparation for creating an application container

The following conditions must be met before creating an application container:

.CDB must exist

.CDB must be in read-write mode

. If the current container is a root of CDB, then the current user must be a public user

. The current user must have create pluggable database system permissions

. A unique application container name must be determined for each application container. Each application container name must be unique to all containers in a single CDB, and each application container name must be unique across all CDB ranges that a particular listener is listening to. The application container name is used to distinguish between application containers in CDB. The application container name follows the same rules as the service name, which is case sensitive.

. If you create an application container in a Data Guard configuration that uses a physical repository, you must complete additional tasks before creating the application container.

. If you use PDB to migrate an existing application into an application container, it must be able to clone the PDB to create the application root, migrate the PDB to the application root, or insert the PDB into the application root.

Create an application container

You can execute create pluggable database... As application container statement to create the application container. The operation to create an application container is as follows:

1. In SQL*Plus, make sure that the current container is the root of CDB.

two。 Execute create pluggable database... As application container statement. You can also specify other clauses if necessary. After the application container is created, it is in mounted mode and its state is NEW. You can query the open_mode column of the v$pdbs view to see the open mode of the application container. You can view the application status by querying the cdb_pdbs or dba_pdbs view. And a new default service is created for the application container. This service has the same name as the application container and can be used to access the application container.

3. Open the new application container in read-write mode. In order to integrate the new application container into CDB, you must open the new application container in read-write mode. If you try to open the application container in read-only mode, it will return to the wrong place. When the application container is opened in read-write mode, its state changes to NORMAL.

4. Backup application container

Use CDB Seed to create an application container

This example assumes that the following conditions are met:

. There are no storage restrictions for application containers. Therefore, the storage clause is not specified.

. The application container does not create a default tablespace

. Do not specify the path_ prefix clause

. The file_name_convert and create_file_ end clauses are not specified. You can enable OMF or set the pdb_file_name_convert parameter. Files related to CDB Seed will be copied to the new directory based on OMF configuration or parameter settings.

. If there is no file store in the target directory with the same name as the new temp file, a new temp file is created, so the tempfile reuse clause is not specified.

. There are no predefined Oracle roles to be granted to the PDB_DBA role.

SQL > create pluggable database salesact as application container admin user salesadm identified by "xxzx"; Pluggable database created.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -PDB$SEED READ ONLYJYPDB READ WRITEORCLPDB READ WRITESALESACT MOUNTEDSQL > alter pluggable database salesact open read write Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -PDB$SEED READ ONLYJYPDB READ WRITEORCLPDB MOUNTEDSALESACT READ WRITE

Create an application container by cloning a local PDB

This example assumes that the following conditions are met:

. Do not specify the path_ prefix clause

. Specify the file_name_ convert clause to specify the directory where the copied files are stored. In this example, the file is derived from the

Copy from + DATA/JY/58E7574E7926075EE053AC828A0AA4C9/DATAFILE/ and + DATA/JY/58E7574E7926075EE053AC828A0AA4C9/TEMPFILE/ directory to + test/jy/hract directory. The create_file_ destination clause is not specified, and the OMF or pdb_file_name_conver parameters are not used.

. Use storage limits for application root. Therefore, you need to specify the storage clause. It is specified here that all tablespaces belonging to the application root cannot exceed 6G in size. This storage limit does not apply to the application PDB attached to the application root.

. No file with the same name as the new temp file exists in the target directory, so a new temp file will be created. Therefore, you do not need to specify the tempfile reuse clause.

SQL > create pluggable database hract as application container from jypdb 2 file_name_convert = ('+ DATA/JY/58E7574E7926075EE053AC828A0AA4C9/DATAFILE/system.297.954436417','+ test/jy/hract/system01.dbf', 3'+ DATA/JY/58E7574E7926075EE053AC828A0AA4C9/DATAFILE/sysaux.276.954436419','+test/jy/hract/sysaux01.dbf', 4'+ DATA/JY/58E7574E7926075EE053AC828A0AA4C9/DATAFILE/undotbs1.296.954436417','+test/jy/hract/undotsb1.dbf' 5'+ DATA/JY/58E7574E7926075EE053AC828A0AA4C9/DATAFILE/undo_2.274.954436487','+test/jy/hract/undo_2.dbf', 6'+ DATA/JY/58E7574E7926075EE053AC828A0AA4C9/TEMPFILE/temp.275.954436435','+test/jy/hract/temp01.dbf' 7) 8 storage (maxsize 6g) Pluggable database created.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -PDB$SEED READ ONLYHRACT MOUNTEDJYPDB READ WRITESALESACT READ WRITE

Create an application container by inserting the unplugged PDB

This example assumes that the following conditions are met:

. The new application container is not created based on the same unplugged PDB that has been used to create the PDB or application container. Therefore, you do not need to specify the as clone clause.

. Do not specify the path_ prefix clause

The .xml metadata file does not accurately describe the current directory of the file, so you need to specify a source_file_name_convert or source_file_ directory clause. In this example, the XML file indicates that the file is in + DATA/JY/DATAFILE/, but the actual file is stored in the + DATA/JY/58E7574E7926075EE053AC828A0AA4C9/DATAFILE/ and + DATA/JY/58E7574E7926075EE053AC828A0AA4C9/TEMPFILE/ directories, specifying the source_file_name_ convert clause.

. The file is stored in the correct directory, so no nocopy clause is specified.

. Use storage restrictions on the application container, so specify the storage clause. Specifies that all tablespaces of the application container do not exceed 4G in size.

. A file with the same name as the new temp file exists in the target directory, in order to create a new temp file. So specify the tempfile reuse clause.

SQL > create pluggable database payrollact as application container using'/ tts/plug/jypdb.xml' 2 source_file_name_convert = ('+ DATA/JY/58E7574E7926075EE053AC828A0AA4C9/DATAFILE/','+ DATA/JY/58E7574E7926075EE053AC828A0AA4C9/DATAFILE/', 3'+ DATA/JY/58E7574E7926075EE053AC828A0AA4C9/TEMPFILE/','+DATA/JY/58E7574E7926075EE053AC828A0AA4C9/TEMPFILE/' 4) 5 nocopy 6 storage (maxsize 4G) 7 tempfile reuse Pluggable database created.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -PDB$SEED READ ONLYPAYROLLACT MOUNTEDSQL > alter pluggable database payrollact open read write Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -PDB$SEED READ ONLYPAYROLLACT READ WRITE

Unplug the application container from CDB

In order to unplug the application container, the following conditions must be met:

. The current user must have sysdba or sysoper administrative privileges

. The application container must be opened at least once

. The application container cannot contain any application PDB

. The application container cannot contain any application Seed

SQL > alter pluggable database payrollact unplug into'/ tts/plug/payrollact.xml';Pluggable database altered.

Delete Application Container

You can use the drop pluggable database statement to delete the application container. You can delete an application container when you want to move it from one CDB to another CDB or when you no longer need the application container.

Deleting an application container is very similar to deleting a PDB. When the application container is deleted, the control file of the CDB is modified to delete the information related to the deleted application container. Archived redo logs and backups related to the application container are not deleted, but they can be deleted using RMAN.

When you delete an application container, you can use the following clause to retain or delete the data file:

. Keep datafiles, the default value, preserves the data file, and even if the keep datafiles clause application container is specified, the temp file will still be deleted because the temp file is no longer needed.

Delete datafiles, delete the data file. If the application container is created using the snapshot copy clause, you must specify the including datafiles clause when deleting the application container.

To delete an application container, the following conditions must be met:

. The application container must be in the mounted state or unplugged state.

. The current user must have sysdba or sysoper administrative privileges.

. The application container cannot contain any application PDB.

. The application container cannot contain any application Seed.

Keep the data file when deleting the application container

Drop pluggable database payrollact keep datafiles

When you delete the application container and delete the data file

This is all the content of the article "how Oracle 12c uses SQL*Plus to create and delete application containers". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report