Amazon RDS - MS SQL DBA Tasks

As a RDS service the MSSQL DB has many DBA tasks available as managed service. You do not have the shell access to the DB, but through the console or through the commands in the client software you can execute various DBA activities. Below are the most common and frequently used DBA tasks performed in Amazon RDS Ms SQL server.

Change Data Capture

CDC captures changes that are made to the data in the tables. The changes that were made to user tables are captured in corresponding change tables. These change tables provide an historical view of the changes over time. The change data capture functions that SQL Server provides enable the change data to be consumed easily and systematically.

Use the below commands in SSMS connected to RDS MSSQL server to enable and disable CDC.

#Enable CDC for RDS DB Instance
exec msdb.dbo.rds_cdc_enable_db ''

#Disable CDC for RDS DB Instance
exec msdb.dbo.rds_cdc_disable_db ''

Next to track the changes in a specific table we use the stored procedure sp_cdc_enable_table with the below command.

#Begin tracking a table
exec sys.sp_cdc_enable_table   
   @source_schema           = N''
,  @source_name             = N''
,  @role_name               = N''
, @captured_column_list   = ''

Modifying tempdb Database Options

The tempdb system database is a global resource which is available to all users connected to the instance of SQL Server and is used to hold the following

  • Temporary user objects that are explicitly created, such as: global or local temporary tables, temporary stored procedures, table variables, or cursors.

  • Internal objects that are created by the SQL Server Database Engine, for example, work tables to store intermediate results for spools or sorting.

  • Row versions that are generated by data modification transactions in a database that uses read-committed using row versioning isolation or snapshot isolation transactions.

Following are examples of How you modify the RDS MSSQL tempdb for various DBA activities.

# setting the size to 100 GB and file growth to 10 percent.
alter database[tempdb] modify file (NAME = N'templog', SIZE=100GB, FILEGROWTH = 10%)

# set the MAXSIZE property to prevent tempdb database from using all available disk space.
alter database [tempdb] modify file (NAME = N'templog', MAXSIZE = 2048MB)

# Shrinking the tempdb Database file size and requests a new size
exec msdb.dbo.rds_shrink_tempdbfile @temp_filename = N'test_file', @target_size = 10;

OFFLINE to ONLINE Transition

You can transition your Microsoft SQL Server database on an Amazon RDS DB instance from OFFLINE to ONLINE using the following command.

EXEC rdsadmin.dbo.rds_set_database_online name

Non-English Character Set

During the creation of RDS MSSQL instance, the default collation marked for the DB is English. But it can be changed to another non-English language by applying the COLLATE clause along with the name of the collation. The below example illustrates that.

CREATE TABLE [dbo].[Account]
    [AccountID] [nvarchar](10) NOT NULL,
    [AccountName] [nvarchar](100) COLLATE Japanese_CI_AS NOT NULL