Menu
Amazon Relational Database Service
User Guide (API Version 2014-10-31)

Common DBA Database Tasks for Oracle DB Instances

This section describes how you can perform common DBA tasks related to databases on your Amazon RDS DB instances running Oracle. To deliver a managed service experience, Amazon RDS doesn't provide shell access to DB instances, and restricts access to certain system procedures and tables that require advanced privileges.

Changing the Global Name of a Database

Changing the global name of a database is supported for Oracle version 11.2.0.4.v1 and later.

You can use the Amazon RDS procedure rdsadmin.rdsadmin_util.rename_global_name to change the global name of a database. The rename_global_name procedure has the following parameters.

Parameter Name Data Type Default Required Description

p_new_global_name

varchar2

required

The new global name for the database.

The database must be open for the name change to occur. For more information about changing the global name of a database, see ALTER DATABASE in the Oracle documentation.

The following example changes the global name of a database to new_global_name.

Copy
exec rdsadmin.rdsadmin_util.rename_global_name(p_new_global_name => 'new_global_name');

Creating and Sizing Tablespaces

Amazon RDS only supports Oracle Managed Files (OMF) for data files, log files and control files. When you create data files and log files, you can't specify the physical file names.

By default, tablespaces are created with auto-extend enabled, and no maximum size. Because of these default settings, tablespaces can grow to consume all allocated storage. We recommend that you specify an appropriate maximum size on permanent and temporary tablespaces, and that you carefully monitor space usage.

The following example creates a tablespace named users2 with a starting size of 1 gigabyte and a maximum size of 10 gigabytes:

Copy
create tablespace users2 datafile size 1G autoextend on maxsize 10G;

The following example creates temporary tablespace named temp01:

Copy
create temporary tablespace temp01;

The Oracle ALTER DATABASE system privilege is not available on Amazon RDS. We recommend that you don't use smallfile tablespaces, because you can only perform some operations, such as resizing existing datafiles, by using the ALTER DATABASE statement.

You can resize a bigfile tablespace by using ALTER TABLESPACE. You can specify the size in kilobytes (K), megabytes (M), gigabytes (G), or terabytes (T).

The following example resizes a bigfile tablespace named users2 to 200 MB:

Copy
alter tablespace users2 resize 200M;

The following example adds an additional datafile to a smallfile tablespace named users2:

Copy
alter tablespace users3 add datafile size 100000M autoextend on next 250m maxsize UNLIMITED;

Setting the Default Tablespace

You can use the Amazon RDS procedure rdsadmin.rdsadmin_util.alter_default_tablespace to set the default tablespace. The alter_default_tablespace procedure has the following parameters.

Parameter Name Data Type Default Required Description

tablespace_name

varchar

required

The name of the default tablespace.

The following example sets the default tablespace to users2:

Copy
exec rdsadmin.rdsadmin_util.alter_default_tablespace(tablespace_name => 'users2');

Setting the Default Temporary Tablespace

You can use the Amazon RDS procedure rdsadmin.rdsadmin_util.alter_default_temp_tablespace to set the default temporary tablespace. The alter_default_temp_tablespace procedure has the following parameters.

Parameter Name Data Type Default Required Description

tablespace_name

varchar

required

The name of the default temporary tablespace.

The following example sets the default tepmorary tablespace to temp01:

Copy
exec rdsadmin.rdsadmin_util.alter_default_temp_tablespace(tablespace_name => 'temp01');

Checkpointing the Database

You can use the Amazon RDS procedure rdsadmin.rdsadmin_util.checkpoint to checkpoint the database. The checkpoint procedure has no parameters.

The following example checkpoints the database:

Copy
exec rdsadmin.rdsadmin_util.checkpoint;

Setting Distributed Recovery

Setting distributed recovery is supported for Oracle version 11.2.0.4.v1 and later.

You can use the Amazon RDS procedures rdsadmin.rdsadmin_util.enable_distr_recovery and disable_distr_recovery to set distributed recovery. The procedures have no parameters.

The following example enables distributed recovery:

Copy
exec rdsadmin.rdsadmin_util.enable_distr_recovery;

The following example disables distributed recovery:

Copy
exec rdsadmin.rdsadmin_util.disable_distr_recovery;

Setting the Database Time Zone

There are two different ways that you can set the time zone of your Amazon RDS Oracle database:

  • You can use the Timezone option.

    The Timezone option changes the time zone at the host level and impacts all date columns and values such as SYSDATE. For more information about the Timezone option, see Oracle Time Zone.

  • You can use the Amazon RDS procedure rdsadmin.rdsadmin_util.alter_db_time_zone.

    The alter_db_time_zone procedure changes the time zone for only certain data types, doesn't change SYSDATE, and is supported only for versions 11.2.0.2.v4 or later. There are additional restrictions on setting the time zone listed in the Oracle documentation.

The alter_db_time_zone procedure has the following parameters.

Parameter Name Data Type Default Required Description

p_new_tz

varchar2

required

The new time zone as an named region or an absolute offset from Coordinated Universal Time (UTC). Valid offsets range from -12:00 to +14:00.

The following example changes the time zone to UTC plus 3 hours:

Copy
exec rdsadmin.rdsadmin_util.alter_db_time_zone(p_new_tz => '+3:00');

The following example changes the time zone to the time zone of the Africa/Algiers region:

Copy
exec rdsadmin.rdsadmin_util.alter_db_time_zone(p_new_tz => 'Africa/Algiers');

After you alter the time zone by using the alter_db_time_zone procedure, you must reboot the DB instance for the change to take effect. For more information, see Rebooting a DB Instance.

Working with Oracle External Tables

Oracle external tables are tables with data that is not in the database. Instead, the data is in external files that the database can access. By using external tables, you can access data without loading it into the database. For more information about external tables, see Managing External Tables in the Oracle documentation.

With Amazon RDS, you can store external table files in directory objects. You can create a directory object, or you can use one that is predefined in the Oracle database, such as the DATA_PUMP_DIR directory. For information about creating directory objects, see Creating New Directories in the Main Data Storage Space. You can query the ALL_DIRECTORIES view to list the directory objects for your Amazon RDS Oracle DB instance.

Note

Directory objects point to the main data storage space (Amazon EBS volume) used by your instance. The space used—along with data files, redo logs, audit, trace, and other files—counts against allocated storage.

You can move an external data file from one Oracle database to another by using the DBMS_FILE_TRANSFER package or the UTL_FILE package. The external data file is moved from a directory on the source database to the specified directory on the destination database. For information about using DBMS_FILE_TRANSFER, see Oracle Data Pump.

After you move the external data file, you can create an external table with it. The following example creates an external table that uses the emp_xt_file1.txt file in the USER_DIR1 directory:

Copy
CREATE TABLE emp_xt ( emp_id NUMBER, first_name VARCHAR2(50), last_name VARCHAR2(50), user_name VARCHAR2(20) ) ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY USER_DIR1 ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE FIELDS TERMINATED BY ',' MISSING FIELD VALUES ARE NULL (emp_id,first_name,last_name,user_name) ) LOCATION ('emp_xt_file1.txt') ) PARALLEL REJECT LIMIT UNLIMITED;

Suppose that you want to move data that is in an Amazon RDS Oracle DB instance into an external data file. In this case, you can populate the external data file by creating an external table and selecting the data from the table in the database. For example, the following SQL statement creates the orders_xt external table by querying the orders table in the database.

Copy
CREATE TABLE orders_xt ORGANIZATION EXTERNAL ( TYPE ORACLE_DATAPUMP DEFAULT DIRECTORY DATA_PUMP_DIR LOCATION ('orders_xt.dmp') ) AS SELECT * FROM orders;

In this example, the data is populated in the orders_xt.dmp file in the DATA_PUMP_DIR directory.

Working with Automatic Workload Repository (AWR)

If you use Oracle Database Enterprise Edition and want to use Automatic Workload Repository (AWR), you can enable AWR by changing the CONTROL_MANAGEMENT_PACK_ACCESS parameter.

Oracle AWR includes several report generation scripts, such as awrrpt.sql, that are installed on the host server. You do not have direct access to the host, but you can copy the scripts from another installation of Oracle Database.

To use Oracle database links with Amazon RDS DB instances inside the same VPC or peered VPCs, the two DB instances should have a valid route between them. Verify the valid route between the DB instances by using your VPC routing tables and network access control list (ACL).

The security group of each DB instance must allow ingress to and egress from the other DB instance. The inbound and outbound rules can refer to security groups from the same VPC or a peered VPC. For more information, see Updating Your Security Groups to Reference Peered VPC Security Groups.

If you have configured a custom DNS server using the DHCP Option Sets in your VPC, your custom DNS server must be able to resolve the name of the database link target. For more information, see Setting Up a Custom DNS Server.

For more information about using database links with Oracle Data Pump, see Oracle Data Pump.

Related Topics