Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

SQL Server / Oracle tabletable only recordable by a trigger&ques ...

$
0
0

I am wondering if is there a way to make a table writable only by an specific trigger in SQL Server or Oracle DB. Just to make an example:

Table: "Operation" ID | Date | Account1_ID | Account2_ID | Amount Table: "Transactions" ID | Date | Account | Debt | Credit

What I want to ensure is that the Transactions table only receive data from a trigger in the Operation table.

Is there a way to achieve that?

Execute As allows you to create a trigger that runs as a user different to the current user. So you can create a separate user who has write access to your TRANSACTIONS table, and execute the trigger as that user.

If no other users have write access, only the trigger user can modify the data.

Of course you then need to make sure nobody can log in as that user, and that you can trust your DBA to manage the account.


Viewing all articles
Browse latest Browse all 3160

Trending Articles