ddl-trigger

SQL server schema auditing?

两盒软妹~` 提交于 2019-12-30 03:31:07
问题 We have a SQL Server 2008 Enterprise database with two different schemas, a locked one that we maintain and an open one that we allow outside development teams to add to and modify for their own needs. Usually this works out OK for us but one particular team likes to really muck it up and it is impacting everyone else. So 2 questions: In hindsight I wish we had set up something robust from the outset but we did not, just the default install. It would be nice to be able to see what has been

How to create DDL trigger to all databases in SQL Server 2005 instance

懵懂的女人 提交于 2019-12-24 01:58:17
问题 I am going to create a DDL trigger to all databases in SQL Server instance. I'd like to do it in one run instead of many runs for each database. Below are the two T-SQL statements I need to execute: -- Create table use <dbname> GO CREATE TABLE dbo.ChangeAttempt (EventData xml NOT NULL, AttemptDate datetime NOT NULL DEFAULT GETDATE(), DBUser char(50) NOT NULL) GO -- Create DDL trigger use <dbname> GO CREATE TRIGGER db_trg_ObjectChanges ON DATABASE FOR ALTER_PROCEDURE, DROP_PROCEDURE, ALTER

execute a trigger when I create a table

不羁岁月 提交于 2019-12-22 01:43:38
问题 I would like to know if a trigger on a system table of PostgreSQL can be executed when I create a table I need to add 2 functions on each table of my database and I would like to do it dynamically Thanks 回答1: I know it's an old question but now it has been implemented in version 9.3, or at least partially http://www.postgresql.org/docs/9.3/static/event-trigger-definition.html 回答2: This can be done with an event trigger: CREATE OR REPLACE FUNCTION on_create_table_func() RETURNS event_trigger

How to get Database Name in a Logon SQL Trigger

↘锁芯ラ 提交于 2019-12-11 06:14:18
问题 How to get Database Name in a Logon Trigger tried several tsql code CREATE TRIGGER tr_stop_excel_users ON ALL SERVER FOR LOGON AS BEGIN IF (SELECT DB_NAME() FROM sys.databases) = 'TESTDB' and ORIGINAL_LOGIN() <> N'xx\xxxxxxx' AND APP_NAME() LIKE '%Microsoft Office%' OR APP_NAME() LIKE '%EXCEL%' OR APP_NAME() LIKE '%ACCESS% ROLLBACK; END above the DB_NAME always yields master I am trying to get Database Name in a Logon Trigger and its not working in any way I try….below the DB_NAME is always

Create a TRIGGER to create a TRIGGER when a table is created

狂风中的少年 提交于 2019-12-10 18:10:00
问题 I am interested in creating a TRIGGER that creates a TRIGGER when a table is created. Poking around in mysql databases, I noticed that the tables for a schema are returned with: select TABLE_NAME, TABLE_SCHEMA from information_schema.TABLES; Is the following a proper method to create a TRIGGER , to create a TRIGGER bound to a different schema? DELIMITER // CREATE TRIGGER `information_schema`.`argus_table_creation` AFTER INSERT on `TABLES` BEGIN --trigger here CREATE TRIGGER `argus`.`after

execute a trigger when I create a table

删除回忆录丶 提交于 2019-12-04 23:19:57
I would like to know if a trigger on a system table of PostgreSQL can be executed when I create a table I need to add 2 functions on each table of my database and I would like to do it dynamically Thanks I know it's an old question but now it has been implemented in version 9.3, or at least partially http://www.postgresql.org/docs/9.3/static/event-trigger-definition.html This can be done with an event trigger : CREATE OR REPLACE FUNCTION on_create_table_func() RETURNS event_trigger AS $$ BEGIN -- your code here END $$ LANGUAGE plpgsql; CREATE EVENT TRIGGER on_create_table ON ddl_command_end

How do I create a Oracle trigger that grants permissions

我怕爱的太早我们不能终老 提交于 2019-11-28 10:53:50
问题 I want to do something that's conceptually simple but seems to be a lot more complex in reality. Basically, whenever a new table is created for a couple of users in our database, I want to grant select permissions to a role. Basically this: grant select on TABLENAME to READROLE; So far my trigger looks something like this: CREATE OR REPLACE TRIGGER osmm_grant_on_creation AFTER CREATE ON OSMM.SCHEMA BEGIN //grant goes here END Problem is, I can't figure out how to join the two together by