Managing Disk Group Directories

Oracle ASM disk groups contain a system-generated hierarchical directory structure for storing Oracle ASM files. The system-generated file name that Oracle ASM assigns to each file represents a path in this directory hierarchy. The following is an example of a system-generated file name:

+data/orcl/CONTROLFILE/Current.256.541956473

The plus sign represents the root of the Oracle ASM file system. The data directory is the parent directory for all files in the data disk group. The orcl directory is the parent directory for all files in the orcl database, and the CONTROLFILE directory contains all control files for the orcl database.

You can create your own directories within this hierarchy to store aliases that you create. Thus, in addition to having user-friendly alias names for Oracle ASM files, you can have user-friendly paths to those names.

This section describes how to use the ALTER DISKGROUP statement to create a directory structure for aliases. It also describes how you can rename a directory or drop a directory. This section contains the following topics:

Creating a Directory

Use the ADD DIRECTORY clause of the ALTER DISKGROUP statement to create a hierarchical directory structure for alias names for Oracle ASM files. Use the slash (/) or backslash (\) character to separate components of the directory path. The directory path must start with the disk group name, preceded by a plus sign (+), followed by any subdirectory names of your choice.

The parent directory must exist before attempting to create a subdirectory or alias in that directory. A directory must be created below the disk group level.

Example 5-10 creates a hierarchical directory for disk group data, which can contain, for example, the alias name +data/orcl/control_file1.

Assuming no subdirectory exists under the directory +data/orcl, the SQL statement fails in Example 5-11.

Example 5-10 Creating a new directory

ALTER DISKGROUP data ADD DIRECTORY '+data/orcl';

Example 5-11 Creating a new subdirectory

ALTER DISKGROUP data
     ADD DIRECTORY '+data/orcl/first_dir/second_dir';

Renaming a Directory

The RENAME DIRECTORY clause of the ALTER DISKGROUP statement enables you to rename a directory. System-created directories (those containing system-generated names) cannot be renamed. The root level (disk group name) cannot be renamed.

Example 5-12 renames a directory.

Example 5-12 Renaming a directory

ALTER DISKGROUP data RENAME DIRECTORY '+data/mydir'
     TO '+data/yourdir';

Dropping a Directory

You can delete a directory using the DROP DIRECTORY clause of the ALTER DISKGROUP statement. You cannot drop a system-created directory. You cannot drop a directory containing alias names unless you also specify the FORCE clause.

Example 5-13 deletes a directory along with its contents.

Example 5-13 Dropping a directory

ALTER DISKGROUP data DROP DIRECTORY '+data/yourdir' FORCE;