Posts

Showing posts with the label Sql

MSSQL server audit

MSSQL Server Auditing on AWS RDS Enable MSSQL Server Auditing on AWS RDS To enable MSSQL server auditing on AWS RDS, please follow these steps: Login to AWS console and go to RDS. Create an option group under RDS > Option groups Give name as 'SqlServerAudit' Provide description as 'Option group for SQL Server audit' Choose the engine as same as the one used while creating the database in RDS. Choose the latest engine version. Save. Go to RDS > Option groups and select the radio button on the option group you just created Click on Add Option. Select SQLSERVER_AUDIT under “Option name” Choose the S3 bucket name where you want to keep the audit files once they grow more than the specified limit. Choose the appropriate IAM role with write access to the S3 bucket. Scheduling > Immediately and then click on “Add Option“....

Delete rows from multiple tables in one query

Hello Reader, In this blog post we will learn how to cascade the delete operation to child table. In a parent-child relationship there are situations when we don't want to leave the Child orphan. Meaning if the parent row is getting deleted we want to delete the associated childs also. The classic way to achieve this situation is to delete all the child rows first and then delete the parent row. The drawback of this approach is that we need to fire 2 queries and both of them should be in a same transaction else it would leave stale data in DB. For eg. if children were deleted successfully but parent was not deleted successfully, now in DB we still have this parent but no children. If we want to delete this relation in a single query then there are then there are two ways to achieve it: 1) FOREIGN KEYS with ON DELETE CASCADE 2) Using JOIN in DELETE query Below example is for mysql: 1) FOREIGN KEYS with ON DELETE CASCADE: This options allows creating FOREIGN KEYS in such a way...