sql - 创建嵌套表列存储表时出错
问题描述
Oracle Database 12c 企业版 12.1.0.2.0 - 64 位生产
寻求专家帮助解决以下错误:
CREATE TABLE "ABC"
(----
----
"STATUSES" "INTLIST" ,
----
"CHAIN_DETAILS" "CHAIN_CFG_LIST" ,
-----
)
NESTED TABLE "STATUSES" STORE AS "OP_STATUSES_NT"
RETURN AS VALUE
NESTED TABLE "CHAIN_DETAILS" STORE AS "op_chains"
RETURN AS VALUE;
给出错误信息:
ORA-02320: 创建嵌套表列存储表时出错状态
ORA-01950: 没有表空间的权限
解决方案
我的猜测是用户在默认表空间上没有配额。您可以通过查询来找到您的默认表空间user_users
,或者如果检查不同的用户,以及来自ordba_users
的配额。值意味着无限。加入这些以查看默认表空间的配额:user_ts_quotas
dba_ts_quotas
-1
select u.username
, u.default_tablespace
, tq.max_bytes
from user_users u
left join user_ts_quotas tq
on tq.tablespace_name = u.default_tablespace;
这对于任何表来说都是一个问题,但如果deferred_segment_creation
设置为true
(默认值),则该错误只会在您尝试向表中添加行时出现,因为这是第一个存储请求。
现在我检查了一下,嵌套表似乎需要立即存储,这可以解释为什么您会收到嵌套表列的错误。
使用测试用户“演示”的示例:
sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri May 11 10:41:51 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> create user demo identified by demo;
User created.
SQL> grant create session, create table, create type to demo;
Grant succeeded.
连接为demo
:
SQL> conn demo/demo
Connected.
SQL> col username format a15
SQL> col default_tablespace format a20
SQL> select u.username
2 , u.default_tablespace
3 , tq.max_bytes
4 from user_users u
5 left join user_ts_quotas tq
6 on tq.tablespace_name = u.default_tablespace;
USERNAME DEFAULT_TABLESPACE MAX_BYTES
--------------- -------------------- ----------
DEMO USERS
我的默认表空间是USERS
,我没有配额,但我可以创建一个表:
SQL> create table demotable(id integer);
Table created.
只有当我需要一些实际存储时才会遇到问题:
SQL> insert into demotable values (1);
insert into demotable values (1)
*
ERROR at line 1:
ORA-01950: no privileges on tablespace 'USERS'
现在尝试使用嵌套表:
SQL> create or replace type demo_tt as table of number(1);
2 /
Type created.
SQL> create table abc
2 ( id integer
3 , statuses demo_tt )
4 nested table statuses store as op_statuses_nt return as value;
create table abc
*
ERROR at line 1:
ORA-02320: failure in creating storage table for nested table column STATUSES
ORA-01950: no privileges on tablespace 'USERS'
我的用户demo
需要一个表空间配额USERS
(通常您授予unlimited
或不授予,但只是为了好玩,让我们分配 1MB ......)
SQL> conn / as sysdba
Connected.
SQL> alter user demo quota 1M on users;
User altered.
SQL> conn demo/demo
Connected.
SQL> select u.username
2 , u.default_tablespace
3 , tq.max_bytes
4 from user_users u
5 left join user_ts_quotas tq
6 on tq.tablespace_name = u.default_tablespace;
USERNAME DEFAULT_TABLESPACE MAX_BYTES
--------------- -------------------- ----------
DEMO USERS 1048576
重试创建表:
SQL> create table abc
2 ( id integer
3 , statuses demo_tt )
4 nested table statuses store as op_statuses_nt return as value;
Table created.
SQL> insert into abc (id, statuses) values (1, demo_tt(1,2,3));
1 row created.
推荐阅读
- reactjs - @material-ui 图标在 Windows 上的反应未解决
- java - Java AWT Graphics2D drawString 方法不适用于阿拉伯文本
- image - 在线设计sharepoint页面相关的查询
- python - TensorFlow 单层网络 Conv2d;无效参数:转置需要大小为 3 的向量。但 input(1) 是大小为 4 的向量
- azure-devops - 我可以为多个服务使用相同的 devops 存储库吗?
- python-3.x - Youtube-dl facebook 视频在远程服务器中询问登录详细信息?
- mysql - 我怎样才能把我的查询变成一个续集查询?
- angular - 在让孩子使用 routeConfig 时面临问题
- c# - 利用 HtmlAgilityPack 中的 HtmlDocument 对象的最佳方式?
- python - 分页不适用于基本的网络爬虫