Permission required: DBA or system administrator. On VMS, to use this command against a database in a group level installation, you must have the VMS CMK RNL privilege.
The auditdb command prints selected portions of the journal for a database. It also creates an audit trail of the changes made to particular tables.
Auditdb does not necessarily give you a complete list of all transactions since the last checkpoint. Reasons for this are:
If you need an accurate list of transactions since the last checkpoint, make sure all users exit the database before you run auditdb, or use the –wait flag. If you run auditdb with the –wait flag, and a large amount of unarchived information is in the log file, there will be a delay before the request is processed.
The auditdb command has the following format:
auditdb dbname[/server_class] [-a][-all] | [-table=tablename
{,tablename} [-file[=filename {,filename}]]] [-bdd-mmm-yyyy[:hh:mm:ss]]
[-edd-mmm-yyyy[:hh:mm:ss]] [#cn] [-iusername] [-inconsistent] [-wait]
[-uusername] [-help]
Specifies the database (one database name only), and the server_class, if required, as described in Standard Flags and Parameters.
Prints journal entries for the system catalogs.
Prints everything in the journal file.
Specifies a particular table or tables for which journal entries are to be printed. Up to 64 table names (and 64 file names if the –file flag is also used) can be specified on the command line. No spaces are allowed in the table list. If this flag is omitted, all tables in the database are audited.
This flag is not valid for system catalogs (-a flag).
The table name can be qualified with a valid schema name in the format schema.tablename, as described in Schema Qualifier.
Specifies that audit output is to go to one or more files. To use this option, you must specify the –table option on tables of fewer than 1948 bytes per row.
If a file list is specified, the number of files must match the number of tables. The audit output of the first tablename goes to the first filename, and so on. No spaces are allowed in the file list.
If the –file flag is present without a list of file names, auditdb creates default file names of the form "tablename.trl" (the file extension is an abbreviation of "trail").
If a list of tables is specified without a list of files, output is presented to the standard output device.
This flag is not valid for system catalogs (-a flag).
The output files produced are in binary (bulk copy) format and contain rows appended to, deleted from, or copied into the tables specified. You can copy the output files into a table that has been created to have a row for each operation against the specified table. For more information, see the Database Administrator Guide.
Prints journal entries for transactions committed after the specified date and time. If you specify a date and omit the time, the time defaults to 00:00:00 (midnight).
If you omit this parameter, auditdb lists transactions starting from the date and time of the most recent checkpoint.
Prints journal entries for transactions committed before the specified date and time. If you specify a date and omit the time, the time defaults to 00:00:00 (midnight).
If you omit this parameter, auditdb lists transactions through the current system date and time.
Prints journal entries for transactions committed starting from an older checkpoint. The checkpoint number n must be a valid checkpoint number (as shown by the infodb command).
If you omit this parameter, auditdb lists transactions starting from the most recent checkpoint.
UNIX: In bash shell, you must place this option in quotes; otherwise characters after the # will be treated as a comment. For example:
auditdb empdata "#c1"
Prints journal entries for actions taken by the specified user.
Lets you view journals that the database has marked as inconsistent. The audit will still fail if core catalogs are inconsistent.
Waits until journals are current before starting the audit. Auditing begins after all archiving is completed on the database, or after the archiver has copied all log file information up to the log file end-of-file when the auditdb request was initiated.
If a large amount of unarchived information is in the log file, there will be a delay before the request is processed.
Note:There is a small delay (typically a few seconds) between when a transaction is committed and when it is visible using auditdb.
Specifies the user for which journal entries are to be printed, as described in Standard Flags and Parameters.
Displays command options.
This command audits the empdata database:
auditdb empdata
This command audits the empdata database, which contains the employee and address tables, and writes the output to the default files employee.trl and address.trl:
auditdb empdata –table=employee,address –file
This command does the same as the previous example, but specifies names for the output files:
auditdb empdata –table=employee,address -file=aud2.trl,aud3.trl
This command creates an audit trail for the employee table in the empdata database, and then uses SQL commands to create a table and copy the default auditdb output files into it.
auditdb empdata –table=employee –file sql empdata
create table empaudit
(date date not null with default,
usrname char(32) not null with default,
operation char(8) not null with default,
tranid1 integer not null with default,
tranid2 integer not null with default,
table_id1 integer not null with default,
table_id2 integer not null with default,
eno I2,
ename char(10),
age I1,
job I2,
salary money,
dept I2);
Windows:
copy table empaudit () from 'C:\WINNT\Profiles\user1\employee.trl'
UNIX:
copy table empaudit () from "/usr/directory/employee.trl";
VMS:
copy table empaudit () from "dev:[directory]employee.trl";