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

Oracle 12c uses SQL*Plus to create and mobile application Seeds

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

Share

Shulou(Shulou.com)06/01 Report--

There are several ways to create an application seeds, including using CDB seed, cloning an existing PDB or Non-CDB, and attaching an uninstalled PDB. You can also remove the application seeds from the application container.

To create a new application seed in the application container, you can execute the create pluggable database statement with the as seed clause. You can use the application seed to provide an application container for the application. Typically, the application of the application container is installed in the application root before the application seed is created. After the application seed is created, it will be synchronized with the application root, so the application is installed in the application seed. After the application seed is created, any PDB created using the application seed installs the application. When the application in the application root is upgraded or patched, the application seed must use the application root to synchronize to apply these changes.

Create an application seed by executing a create pluggable database statement with an as seed clause.

An application container can have zero or an application seed. When you create an application seed using the as seed clause, you do not need to specify its name. The application seed name is always named after application_container_name$SEED, where application_container_name is the name of the application container for the application seed. For example, the name of the application seed in the salesact application container must be salesact$SEED.

When you create a new application seed, you must specify an administrator for the application container in the create pluggable database statement. This statement will create an administrator for the local user in the application container and be granted the pdb_dba role.

The conditions required to create an application seed:

.CDB must exist

.CDB must be in read-write mode

. The application container to which the application seed belongs must be in read-write mode

. The current user must be a public user, and the application root to which the application seed belongs is the current container

. The current user has create pluggable database system permissions

. In the application container, for the application seed that contains the application, the application must be installed in the application root

Create an application seed

You can create an application by executing a create pluggable database statement with an as seed clause. The application seed in the application container is similar to seed in CDB. An application seed can be used to quickly and easily create an application PDB that meets the requirements of the application container. The operation to create an application seed is as follows:

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

two。 Execute the create pluggable database statement with the as seed clause to create the application seed. Other clauses can be specified as needed. After the application seed is created, it is in mounted mode with a state of new. You can check the open mode of the application seed by querying the open_mode column of the v$pdbs view. You can view the status of the application seed by querying the status column of the cdb_pdbs or dba_pdbs view. A default service name is also created for the application seed. The service name has the same name as the application seed and can be used to access the application seed.

3. Open a new application seed in read-write mode

4. In order to integrate the new application seed into the application container, the new application seed must be opened in read-write mode. If you try to open a new application seed in read-only mode, an error message will be returned. When the application seed is opened in read-write mode, its status will be normal.

5. Do one or more of the following:

5.an if you create an application seed in CDB seed, switch the container to the application seed and execute the alter pluggable database statement with the sync clause to synchronize the application seed. Applications that synchronously use the application root to instantiate one or more applications in the application seed, root.

5.B if you use the application root to create the application seed, switch the container to the application seed, and then execute the pdb_to_apppdb.sql script to convert the application root to the application PDB.

These operations do not need to be performed when an application seed is created by cloning an application PDB.

6. Close the application seed and open it in read-only mode.

7. Back up the application seed.

Use CDB seed to create an application seed

This example assumes that the following conditions are met:

. The application seed will be created in an application container named salesact.

. No storage restrictions are used for the application seed, so no storage clause is specified.

. The application seed does not create default tablespaces.

. The path_ prefix clause is not specified.

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

. No file with the same name as the new temp file exists in the target directory, a new temp file will be created, so there is no need to specify the tempfile reuse clause.

. There is no need to predefine the Oracle role to be granted to the pdb_dba role.

The statement executed is as follows:

Switch to the application container salesact first

SQL > alter session set container=salesact;Session altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITE

Execute the statement to use CDB seed to create the application seed in the application container salesact and open the application seed.

SQL > create pluggable database as seed admin user actseedadm identified by "xxzx7817600"; Pluggable database created.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESACT$SEED MOUNTEDSQL > alter pluggable database salesact$seed open Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESACT$SEED READ WRITE

Switch containers to the application seed (salesact$SEED) and use all the applications in the application root to synchronize the application seed.

SQL > alter session set container=salesact$seed;Session altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT$SEED READ WRITESQL > alter pluggable database application all sync Pluggable database altered.

Close the application seed (salesact$seed) and open the application seed in read-only mode.

SQL > alter pluggable database close immediate;Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT$SEED MOUNTEDSQL > alter pluggable database open read only Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT$SEED READ ONLY

Because the application container is named salesact, the application seed is called salesact$seed. A local administrative user was created together when the application seed was created and was granted the pdb_dba public role. If this user does not grant administrative privileges when creating the application seed, then use the sys and system public users to manage the application seed. When an application seed is created, the application root is used to synchronize the application seed. So the application seed will contain the applications and application public objects installed in the application root that are part of these applications. When you use the application seed to create a new application PDB, the application PDB also contains these installed applications and application public objects.

Create an application seed using the application PDB

This example assumes that the following conditions are met:

. The application seed is created in the application container salesact.

. The application seed will be created in the same application container as the application PBD (salesapppdb).

. No storage restrictions are used for the application seed, so no storage clause is specified.

. The application seed does not contain the default tablespace.

. The path_ prefix clause is not specified.

. The file_name_convert and create_file_ end clauses are not specified. You can enable OMF or set pdb_file_name_convert initialization parameters. Files related to the application root are copied to the new directory based on the configuration or initialization parameter settings of the OMF.

. No file with the same name as the new temp file exists in the target directory, so you don't need to use the tempfile reuse clause.

Switch the container to the application container (salesact) and execute the following command to create the application seed.

SQL > create pluggable database as seed from salesapppdb;Pluggable database created.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESAPPPDB READ WRITESALESACT$SEED MOUNTED

Then open the application seed, close the application seed, and finally open the application seed as read-only.

SQL > alter pluggable database salesact$seed open;Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESAPPPDB READ WRITESALESACT$SEED READ WRITESQL > alter pluggable database salesact$seed close immediate Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESAPPPDB READ WRITESALESACT$SEED MOUNTEDSQL > alter pluggable database salesact$seed open read only Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESAPPPDB READ WRITESALESACT$SEED READ ONLY

Because the application container is named salesact, the application seed name defaults to salesact$seed. The application seed is created using the application pdb, so the application seed contains the applications and application public objects installed in the application root, which are part of these applications. When you use the application seed to create a new application pdb, the application pdb also contains the installed application and application public objects.

Use the application root to create the application seed

This example assumes that the following conditions are met:

. The application seed will be created in the application container (salesact). The application seed is created by cloning the root of the application container.

. No storage restrictions are used for the application seed, so the story clause is not used.

. The application seed does not contain the default tablespace.

. Do not use the path_ prefix clause.

. File_name_convert and create_file_ end clauses are not used. You can enable OMF or set pdb_file_name_convert initialization parameters. Files related to the application root based on the OMF configuration or initialization parameters are copied to the new directory.

. No file with the same name as the new temp file exists in the target directory, so you don't need to use the tempfile reuse clause.

Switch to the application container (salesact) and execute the following command to create the application seed.

SQL > create pluggable database as seed from salesact;Pluggable database created.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESACT$SEED MOUNTEDSALESAPPPDB READ WRITE

Open the application seed, switch the container to the application seed, and then execute the pdb_to_apppdb.sql script to convert the application root to the application pdb.

SQL > alter pluggable database salesact$seed open;Warning: PDB altered with errors.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESACT$SEED READ WRITESALESAPPPDB READ WRITESQL > alter session set container=salesact$seed Session altered.SQL > @ $ORACLE_HOME/rdbms/admin/pdb_to_apppdb.sql...SQL > BEGIN 2 execute immediate'& open_sql & restricted_state'; 3 EXCEPTION 4 WHEN OTHERS THEN 5 BEGIN 6 IF (sqlcode-900) THEN 7 RAISE; 8 END IF; 9 END; 10 END; 11 / PL/SQL procedure successfully completed.SQL > SQL > WHENEVER SQLERROR CONTINUE;SQL > alter pluggable database close immediate instances=all;Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT$SEED MOUNTED1 row selected.SQL > alter pluggable database open read only instances=all Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT$SEED READ ONLY1 row selected.

Because the application container is named salesact, the application seed is called salesact$seed. The application seed is created using the application root. Therefore, the application seed contains the applications and application public objects installed in the application root, which are part of these applications. When you use the application seed to create a new application PDB, the application pdb also contains the installed application and application public objects.

Unplug the application seed from the application container

To unplug the application seed is to disassociate the application seed from the application container. You can delete the application seed when it is no longer needed. Unplugging the application seed is similar to unplugging the PDB. To unplug the application seed, connect to its application root and use the alter pluggable database statement to specify that the xml file or .pdb file is generated. When the xml file is specified, the xml file generated after the uninstall is complete contains metadata that describes the application seed.

SQL > alter pluggable database salesact$seed close immediate instances=all;Pluggable database altered.SQL > select name,open_mode from v$pdbs NAME OPEN_MODE -SALESACT READ WRITESALESACT$SEED MOUNTEDSALESAPPPDB READ WRITE3 rows selected.SQL > alter pluggable database salesact$seed unplug into'/ tts/plug/salesact_seed.xml' Pluggable database altered.

Delete application seed

When the application seed is no longer needed, you can execute the drop pluggable database statement to delete it. When you delete an application seed, the control file of the CDB is modified to delete all information related to the deleted application seed, but the archive redo logs and backups are not deleted, but they can be deleted using RMAN.

SQL > drop pluggable database salesapppdb including datafiles;Pluggable database dropped.

Create an application PDB

You can create an application PDB by executing create pluggable database statements in the application root container. Creating an application pdb uses the same SQL statement as creating a PDB in CDB root. When the create pluggable database statement is executed in the application root, the newly created PDB is the application PDB. The SQL statement must be executed in the application root and has an explicit dependency on the application database defined in the application root. The operation to create an application PDB is as follows:

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

two。 Execute the create pluggable database statement. After the application PDB is created, it is in mounted mode and the state is NEW. You can view the open mode of the application pdb by querying the open_mode column of the v$pdbs view, and the status of the application pdb by querying the status column of the cdb_pdbs or dba_pdbs view. A default service name is also created for the newly created application PDB, which has the same name as the application PDB and can be used to access the application PDB.

3. Open the application PDB in read-write mode

4. In order to integrate the new application PDB into the application container, the new application PDB must be opened in read-write mode. If you try to open the application PDB in read-only mode, an error message will be returned. After the application PDB is opened in read-write mode, its state changes to NORMAL.

5. Switch the container to the application PDB

6. Execute alter pluggable database... Sync to synchronize the application PDB. Use the application PDB synchronously to instantiate the application in one or more application root in the application PDB.

7. Close the application PDB and open it in read-only mode.

8. Back up the application PDB.

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