Oracle 序列存储在哪个表空间中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/433009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What tablespace are Oracle sequences stored in?
提问by Luke Woodward
The app my colleagues and I maintain has an Oracle database at the back-end. We're looking at occasionally running the app in a 'restricted' mode with one of the database tablespaces set to read-only. We can easily move the necessary tables and indexes over to separate tablespaces which will be writable in 'restricted' mode. However, despite several Google searches I can't determine in which tablespace Oracle stores sequences.
我和我的同事维护的应用程序在后端有一个 Oracle 数据库。我们正在考虑偶尔以“受限”模式运行应用程序,其中一个数据库表空间设置为只读。我们可以轻松地将必要的表和索引移动到单独的表空间,这些表空间将在“受限”模式下可写。但是,尽管进行了几次 Google 搜索,我还是无法确定 Oracle 将序列存储在哪个表空间中。
This answermentions that sequence values are stored in the SYSTEM.SEQ$ table. I don't have access to an Oracle DB right now, but I would guess that this table lives in one of the system tablespaces. The tablespace we are making read-only isn't a system tablespace, it's one of our own data tablespaces.
这个答案提到序列值存储在 SYSTEM.SEQ$ 表中。我现在无法访问 Oracle 数据库,但我猜想该表位于系统表空间之一中。我们设置为只读的表空间不是系统表空间,而是我们自己的数据表空间之一。
On a dev database I can successfully SELECT from a sequence with the relevant tablespace made read-only.
在开发数据库上,我可以成功地从相关表空间设为只读的序列中进行 SELECT。
I suspect it won't be a problem to have this tablespace read-only, but I'd rather my suspicions were confirmed by more than just ad-hoc experimentation. Could someone please enlighten me?
我怀疑将此表空间设为只读不会有问题,但我宁愿我的怀疑不仅仅通过临时实验来证实。有人可以启发我吗?
回答by Gary Myers
Sequences are (mostly) in SEQ$. Parts will be in OBJ$ (and grants elsewhere). But all these tables are in the SYSTEM tablespace. Some SYSTEM objects are in SYSAUX. DBA_SEGMENTS is a good view to identify which tablespaces an object (such as SEQ$) resides in.
序列(大部分)在 SEQ$ 中。部分将在 OBJ$(和其他地方的赠款)。但是所有这些表都在 SYSTEM 表空间中。某些 SYSTEM 对象位于 SYSAUX 中。DBA_SEGMENTS 是识别对象(例如 SEQ$)驻留在哪些表空间的好视图。
I suspect that Oracle wouldn't let you put these tablespaces into READ ONLY mode as, to do so, it would need to flag that tablespace as read only which is recorded in a SYSTEM table in that tablespace. Sort of like locking the key in the safe which it unlocks.
我怀疑 Oracle 不会让您将这些表空间置于 READ ONLY 模式,因为要这样做,它需要将该表空间标记为只读,该表空间记录在该表空间的 SYSTEM 表中。有点像将钥匙锁在它解锁的保险箱中。
回答by tuinstoel
I guess it is system, where else to store this information?
我猜这是系统,还有什么地方可以存储这些信息?
But why do you want to know this? If a tablespace is readonly you can't insert or update so you don't have to use the sequence(s) at all.
但是你为什么想知道这个?如果表空间是只读的,则无法插入或更新,因此根本不必使用序列。
回答by Moshe
I don't have an Oracle DB in front of me right now, be if I recall correctly, sequences are part of the Data Dictionary, and thus cannot be updated manually, and even cannot be (simply) queried without the special syntax (this is why you cannot simply get the current value of a sequence - you must increment it). Obviously, the Data Dictionary is part of the SYSTEM tablespace, and should be touched by any means.
我现在面前没有 Oracle DB,如果我没记错的话,序列是数据字典的一部分,因此无法手动更新,甚至无法(简单地)在没有特殊语法的情况下进行查询(这这就是为什么您不能简单地获取序列的当前值 - 您必须增加它)。显然,数据字典是 SYSTEM 表空间的一部分,应该以任何方式触及。