github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/queries/ddl/statement.sql (about)

     1  -- Content managed by Project Forge, see [projectforge.md] for details.
     2  -- {% func StatementDrop() %}
     3  if exists (select * from sysobjects where name='statement' and xtype='U')
     4  drop table "statement";
     5  -- {% endfunc %}
     6  
     7  -- {% func StatementCreate() %}
     8  if not exists (select * from sysobjects where name='statement' and xtype='U')
     9  create table "statement" (
    10    "id" uniqueidentifier not null,
    11    "session_id" int not null,
    12    "action" nvarchar(255) not null,
    13    "succeeded" bit not null,
    14    "principal" nvarchar(max) not null,
    15    "database" nvarchar(max) not null,
    16    "filename" nvarchar(max) not null,
    17    "host" nvarchar(max) not null,
    18    "transaction_id" int not null,
    19    "client_ip" nvarchar(max) not null,
    20    "duration" int not null,
    21    "connection_id" uniqueidentifier not null,
    22    "rows_affected" int not null,
    23    "rows_returned" int not null,
    24    "sql" nvarchar(max) not null,
    25    "types" nvarchar(max) not null,
    26    "values" nvarchar(max) not null,
    27    "occurred" datetime not null,
    28    primary key ("id")
    29  );
    30  
    31  if not exists (select * from sys.indexes where name='statement' and object_id=object_id('statement__action_idx'))
    32  create index "statement__action_idx" on "statement" ("action");
    33  -- {% endfunc %}