Previous Topic

Next Topic

Book Contents

Book Index

SQL history

The SQL history can be accessed from the Run SQL window. Click on the History icon, File > SQL History or Ctrl+H.

History

Show SQL for History Run From

You can run SQL from a number of places in AQT. By default, only SQL run from the Run SQL window is recorded in the SQL History. However, in Options > History you can specify to include SQL run:

The menu item Show History for SQL Run From allows you to specify which of these SQL statements are shown in the History display.

History Files

Information is (by default) written to aqt_history.txt in your default directory. You can change the directory where the history file(s) are written with Options > File Locations.

AQT holds SQL history indefinitely. If you history file becomes very large it can take a while to open the SQL History window.

If this happens, you should do one of the following:

If you have multiple History files, you can open a particular one with File > Open.

When are history records written?

History records are written to disk as soon as a query is run.

AQT writes a maximum of 20,000 bytes of an SQL statement and 1000 bytes of the result message to the history record. If you have a very large SQL statement you may notice that it is truncated when you retrieve it from the History. In this case you should save the SQL statement to disk rather than relying on the History to "save" it.

If you run the same SQL statement multiple times, this will only be written to the History the first time it is run.

History and Queries

When your SQL statement is a saved-query (eg. is SQL you have saved or retrieved from disk), the information on the query filename is recorded with the history record. When you click on the SQL in the history grid, the information in the status bar (at the bottom of the window) will tell you the name of this saved query.

When you retrieve the SQL from the History, AQT will associate the query with your SQL:

Database

When you retrieve some SQL, AQT will not change the database in the Run SQL window to the database in the history record.

However if you use Retrieve into new Window, AQT will set the database in this new Run SQL window to the database in the History record.

Procedure History

AQT also records the running of Stored Procedures from the Run Procedure window. The history entries for these are recorded in file aqt_prochistory.txt. These history records also includes the parameters passed to the stored procedure; this can be useful when rerunnng a procedure run earlier.

Many of the considerations of these history records are the same as for the SQL History.

Audit Feature

In addition to the SQL History feature, there is also the Audit Feature. While this records similar information, the audit feature has a number of different options more oriented to long-term recording of update (non-query) activity.

Copying SQL Text

You may wish to copy a number of SQL statements, for instance to replay a script. You can do this as follows:

histcopy