Amazon RDS: tareas de DBA de MS SQL

Como servicio RDS, MSSQL DB tiene muchas tareas de DBA disponibles como servicio administrado. No tiene acceso de shell a la base de datos, pero a través de la consola o mediante los comandos en el software cliente puede ejecutar varias actividades de DBA. A continuación, se muestran las tareas de DBA más comunes y más utilizadas que se realizan en el servidor SQL de Amazon RDS Ms.

CDC captura los cambios que se realizan en los datos de las tablas. Los cambios que se realizaron en las tablas de usuario se capturan en las tablas de cambios correspondientes. Estas tablas de cambios proporcionan una vista histórica de los cambios a lo largo del tiempo. Las funciones de captura de datos modificados que proporciona SQL Server permiten que los datos modificados se consuman de forma fácil y sistemática.

Utilice los siguientes comandos en SSMS conectado al servidor RDS MSSQL para habilitar y deshabilitar 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 
) ON [PRIMARY];