Oracle 权限问题

Jus*_*ner 3 oracle permissions

请参阅以下声明。我的问题是,表 t1 是在用户表空间中创建的,因此它会占用一些空间。但是为什么它可以在我对用户表空间施加配额之前创建?

谢谢。

sys@ORCL>create user a identified by a account unlock;

User created.

sys@ORCL>create table a.t1(c int);

Table created.

sys@ORCL>select owner, table_name, tablespace_name from dba_tables where table_name = 'T1';

OWNER                  TABLE_NAME             TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
A                  T1                 USERS

sys@ORCL>insert into a.t1 values(1);
insert into a.t1 values(1)
              *
ERROR at line 1:
ORA-01950: no privileges on tablespace 'USERS'


sys@ORCL>alter user a quota 10M on users;

User altered.

sys@ORCL>insert into a.t1 values(1);

1 row created.

sys@ORCL>commit;

Commit complete.

sys@ORCL>
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我已经测试过使用用户a在用户被强加配额之前创建表。(假设用户具有创建会话和创建表的权限)仍然可以创建表。但在我的示例中,我使用SYS用户创建表。

编辑:

这是版本信息:

sys@ORCL>select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0  Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

sys@ORCL>
Run Code Online (Sandbox Code Playgroud)

Jus*_*ave 5

由于延迟段创建

在 Oracle 11.2 中,当您创建一个没有数据的表时,您不再在表空间中分配任何空间。在您尝试将数据插入表中之前,Oracle 不会实际创建段。这与在创建表而不是在插入数据时创建段的早期版本不同。

新功能的原因是市场上有很多打包的应用程序,它们可能会创建数百个永远不会有数据的表,因为客户没有使用使用这些表的项目的某些特定模块。例如,对于打包大型 ERP 工具的人来说,最终分配给永远不会有任何数据的表的潜在空间为 GB,这很烦人。

如果您已设置COMPATIBLE为 11.2 并且DEFERRED_SEGMENT_CREATION设置为默认值,则您只会看到延迟段创建TRUE

SQL> conn / as sysdba
Connected.
SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      11.2.0.0.0
SQL> show parameter deferred

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
deferred_segment_creation            boolean     TRUE
SQL> create user deferred identified by deferred default tablespace users;

User created.

SQL> crant create table, create session to deferred;
SP2-0734: unknown command beginning "crant crea..." - rest of line ignored.
SQL> grant create table, create session to deferred;

Grant succeeded.

SQL> conn deferred/deferred
Connected.
SQL> create table test( col1 number );

Table created.

SQL> insert into test values( 1 );
insert into test values( 1 )
            *
ERROR at line 1:
ORA-01950: no privileges on tablespace 'USERS'
Run Code Online (Sandbox Code Playgroud)