31
Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 1 Lab 1 - Managing Pluggable Databases (PDBs) using SQL Developer Contents Overview ................................................................................................................................... 2 Setting up the Environment ................................................................................................. 3 Creating a Database Connection ................................................................................. 3 Adding a Connection to the DBA Navigator .............................................................. 5 Modifying the State of a Pluggable Database .................................................................... 7 Cloning a Pluggable Database .......................................................................................... 11 Unplugging and Plugging a Pluggable Database ............................................................ 19 Unplugging the Database............................................................................................ 19 Plugging in the Database ............................................................................................ 23 Create a Pluggable Database ........................................................................................... 25 Summary ............................................................................................................................. 31

Lab 1 - Managing Pluggable Databases (PDBs) using SQL ...€¦ · Unplugging and Plugging a Pluggable Database Unplugging the Database You can unplug a database from one container

  • Upload
    others

  • View
    18

  • Download
    1

Embed Size (px)

Citation preview

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 1

Lab 1 - Managing Pluggable Databases (PDBs) using SQL Developer

Contents Overview ................................................................................................................................... 2

Setting up the Environment ................................................................................................. 3

Creating a Database Connection ................................................................................. 3

Adding a Connection to the DBA Navigator .............................................................. 5

Modifying the State of a Pluggable Database .................................................................... 7

Cloning a Pluggable Database .......................................................................................... 11

Unplugging and Plugging a Pluggable Database ............................................................ 19

Unplugging the Database ............................................................................................ 19

Plugging in the Database ............................................................................................ 23

Create a Pluggable Database ........................................................................................... 25

Summary ............................................................................................................................. 31

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 2

Overview

Purpose

This HOL describes four important activities to help you manage pluggable databases.

Time to Complete

Approximately 45 minutes

Introduction

The HOL covers the three following activities:

o Modifying the state of a pluggable database o Creating a pluggable database from an existing pluggable database o Unplugging and plugging a pluggable database o Creating a pluggable database from seed PDB

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 3

Setting up the Environment

Creating a Database Connection

Open Oracle SQL Developer by double-clicking the SQL Developer desktop icon.

The Oracle SQL Developer window is displayed.

On the Connections tab, right-click Connections and select New Connection.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 4

The New / Select Database Connection dialog box is displayed.

Enter parameters for the new connection. In this example, the entries are:

Name: sys Username: sys Password: Enter the password for your system.( oracle in this HOL) Save Password: Selected Connection Type: Basic Role: SYSDBA Hostname: localhost Port: 1521 SID: orcl

Click Test and confirm a status of "Success."

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 5

Click Save.

Close the New / Select Database Connection dialog box.

Adding a Connection to the DBA Navigator

In SQL Developer, the DBA Navigator enables you to perform full administration of container databases and pluggable databases.

Select View > DBA.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 6

On the DBA tab, right-click Connections and select Add Connection.

In the Select Connection dialog box, select sys and click OK.

The sys connection is added to the DBA Navigator.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 7

Modifying the State of a Pluggable Database

Before you can clone a pluggable database, it has to be Closed and Opened in Read Only mode.

Expand the sys connection. In the Container Database node, right-click PDB1 and select Modify State.

The Modify Pluggable State dialog box is displayed. Since database PDB1 is closed, the value of New State is OPEN. Click to open the State Option list. Select READ ONLY.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 8

Click Apply.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 9

When the success message is displayed, click OK.

Right-click PDB1 and select Open. Then a new tab will be opened for PDB1.

In the PDB1 tab, under General, confirm that the value for OPEN_MODE is READ ONLY.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 10

Click DataFiles to see the datafiles belong to PDB1.

You are now ready to create a new Pluggable Database by cloning an existing Pluggable Database.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 11

Cloning a Pluggable Database

You can create additional pluggable databases by cloning an existing pluggable database. Perform the tasks below to create a clone of PDB1 named PDB2.

Expand the sys node and then the Container Database node.

Right click PDB1 and select Clone.

The Clone Pluggable Database dialog box is displayed.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 12

On the Properties tab, provide the parameters for cloning. In this example, the parameters are:

Database Name: PDB2 Source PDB: PDB1 Database Link: NONE (default) Storage: Unlimited File Name Conversions: Custom Expressions (creates datafiles for your new PDB2 by copying the files from the PDB1 datafiles).

When you select Custom Expressions , Click . Enter pdb1 for Source File Pattern and pdb2 for Target File Pattern.

Please notice that the entered “pdb1” of source file pattern in the figure above should be in lower case.

Click the SQL tab to view the CREATE statement (optional), and then click Apply.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 13

When the success message is displayed, click OK.

PDB2 is now created and displayed under Container Database.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 14

To view the data files for the cloned database, click PDB2.

Click the DataFiles tab to view the data files.

Right click on PDB2, and select Modify State to open the pluggable database.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 15

Click Apply to Open PDB2.

When the success message is displayed, click OK.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 16

The clone of database has complete. We will bring PDB1 back to normal state.

Right-click PDB1 and select Modify State.

The Modify Pluggable State dialog box is displayed. Since database PDB1 is opened, the value of New State is CLOSE. Click Apply.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 17

Right-click on PDB1 and select Modify State.

Click to open the State Option list. Select READ WRITE and click Apply.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 18

When the success message is displayed, click OK.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 19

Unplugging and Plugging a Pluggable Database

Unplugging the Database

You can unplug a database from one container database and later plug it into the same (or another) container database.

A Pluggable Database has to be 'Closed' before it can be unplugged. In the Container Database tree, right-click PDB2 and select Modify State.

Click Apply to 'Close' PDB2.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 20

In the Container Database tree, right-click PDB2 and select Unplug Pluggable Database.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 21

In the Unplug Database dialog box, confirm the database name PDB2 and input the XML file name to /home/oracle/PDB2.XML. The XML file stores the location of the data files for the unplugged database.

Optional: To view the code, click SQL, view the code. Click Properties to go back to properties page.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 22

Click Apply.

PDB2 is no longer displayed in the Container Database tree.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 23

Plugging in the Database

Note: The steps for plugging a PDB into a different container database are essentially the same as those for plugging it into the container database from which it was unplugged. Here, you will plug PDB2 back into the same container database--while recognizing that, in the real world, selecting a different container database would make more business sense.

In the Connections tree, right-click the Container Database node, and then select Plug In Pluggable Database.

The Plug Database dialog box is displayed.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 24

Enter the following: Database Name: PDB2 XML File Name: Enter the directory path where PDB2.XML resides. In previous step, we have put the XML file to /home/oracle/PDB2.XML.

Click Apply.

Database PDB2 is plugged in and, once again, appears in the Container Database tree.

(Note: If you want to unplug the PDB2 again, please at least open and close it once.)

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 25

Create a Pluggable Database

You can create pluggable databases from the seed pluggable database call seed$pdb. Perform the tasks below to create a new pluggable database PDB3.

Expand the sys node and then the Container Database node.

Right click Container Database and select Create Pluggable Database.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 26

The Create Pluggable Database dialog box is displayed.

On the Properties tab, provide the parameters for creating. In this example, the parameters are:

Database Name: PDB3 Admin name: admin Admin password: oracle Storage: Unlimited File Name Conversions: Custom Name.

When you select Custom Name, enlarge the "Create Pluggable Database" dialog box by putting the mouse in the right-down corner and drag it.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 27

Change the target file names to under directory /oradata/ORCL/datafile/pdb3, they will be:

/oradata/ORCL/datafile/pdb3/system01.dbf

/oradata/ORCL/datafile/pdb3/sysaux01.dbf

/oradata/ORCL/datafile/pdb3/temp01.dbf

Then click Apply to create the pluggable database.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 28

When the success message is displayed, click OK.

PDB3 is now created and displayed under Container Database.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 29

To view the data files for the new database, click PDB3.

Click the DataFiles tab to view the data files.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 30

Right click on PDB3, and select Modify State to open the pluggable database.

Click Apply to Open PDB3.

Copyright ©2013, Oracle and/or its affiliates. All rights reserved. 31

When the success message is displayed, click OK.

Summary

This HOL described three important activities to help you manage pluggable databases.

In this HOL, you learned how to:

o Modify the state of a pluggable database o Create a pluggable database from an existing pluggable database o Unplug and plug a pluggable database o Create a pluggable database from seed PDB