简体   繁体   English

TypeORM:只读连接(Oracle)

[英]TypeORM: Read Only Connection (Oracle)

I'm using TypeORM and I was wonderring if there's a way to prevent any edit to the database. 我正在使用TypeORM ,我想知道是否有一种方法可以防止对数据库进行任何编辑。 I'm not totally sure if my entities will create or edit columns or tables in the database and I don't want that to happen like when setting relations between the tables, I don't want TypeORM to create a new foreign key if it does not exists. 我不确定我的实体是否会在数据库中创建或编辑列或表,并且我不希望那样发生,例如在设置表之间的关系时,我不希望TypeORM创建新的外键不存在。

I suppose you could create a DDL trigger that raises an exception. 我想您可以创建引发异常的DDL触发器。

create or replace trigger prevent_ddl_trg 
before ddl on schema
declare
begin
  raise_application_error(-20001, 'DDL not allowed')
end;

In 11.2 and higher, this seems to allow alters and drops on the trigger itself. 在11.2及更高版本中,这似乎允许对触发器本身进行更改和删除。

You can disable with: 您可以通过以下方式禁用:

alter trigger prevent_ddl_trg disable;

And enable with: 并启用:

alter trigger prevent_ddl_trg enable;

Be careful with that though, you may prevent things you weren't expecting, like the ability to reset your own password. 不过请务必小心,以免发生意想不到的事情,例如能够重置自己的密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM