[SQLServer Development]SQL audit
Created#More Posted time:Aug 3, 2016 16:54 PM
You can use the RDS Console or APIs to check SQL details and periodically audit SQL, so as to detect problems timely. Currently, only ApsaraDB for MySQL supports SQL audit.
1. You can use SQL Details and binlog to check incremental data of ApsaraDB for MySQL. There are some differences between the two.
1) SQL Audit: Similar to audit log of MySQL, SQL Audit collects statistics on all DML and DDL operation information. Some of the information is obtained through network protocol analysis. SQL Audit does not parse actual parameter values, and a small amount of records may be lost when the SQL query volume is large. Therefore, this method may result in inaccurate incremental data statistics.
2) binlog: It accurately records all ADD, DELETE and MODIFY operations performed on the database, and can accurately recover the user’s incremental data. However, binlogs are firstly stored in an instance. The system periodically migrates full binlogs to OSS and stores the binlogs for seven days. Binlogs which are not full cannot be saved (it is why part of binlogs are not uploaded when you click One-click Binlog Upload). In this way, the incremental data of the database can be accurately recorded, but logs cannot be obtained in real time.
2. SQL audit records are retained for 30 days.
3. SQL Audit is disabled by default. If SQL Audit is enabled, additional charges are incurred. For detailed charges, refer to RDS Price.
1. Log in to the RDS Console and select the target instance.
2. Select Data Security in the instance menu.
3. On the Data Security page, click SQL Audit and then Enable SQL Audit, as shown in the figure below.
4. After enabling SQL Audit, you can query SQL information based on criteria such as time, DB, user and key words.
Disabling SQL audit
To disable SQL Audit so as to avoid additional charges, you can click Disable SQL Audit on the SQL Audit page.When SQL Audit is disabled, contents of SQL Audit, including historical audit contents, cannot be viewed.