查询表是否开启了并行度,可以查看视图dba_tables的degree字段,该字段为varchar2类型。使用查询语句是需要在degree字句中添加引号’’,如下所示:
SYS@10G > desc dba_tables;
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER NOT NULL VARCHAR2(128)
TABLE_NAME NOT NULL VARCHAR2(128)
TABLESPACE_NAME VARCHAR2(30)
...
DEGREE VARCHAR2(10)
SYS@10G > select owner,table_name,degree from dba_tables where degree ='4';
这个查询在Oracle10g中可以执行,但是在12.1.0.1中会出错。你会发现无论将degree设置成任何值都查不到数据,及时设置为1也没有数据。
SYS@12C > select owner,table_name,degree from dba_tables where degree ='1';
no rows selected
使用PLSQL Developer工具对dba_tables表查询时,仔细观察degree字段会发现数值都不是左对齐的,也就是说存在空格。
既然判断出问题了,使用trim函数解决。
SYS@12C > col owner for a20
SYS@12C > col table_name for a30
SYS@12C > col degree for a20
SYS@12C > set lines 100
SYS@12C > select owner,table_name,degree from dba_tables where trim(degree) = '1' and rownum < 6
SYS@12C > /
OWNER TABLE_NAME DEGREE
-------------------- ------------------------------ --------------------
SYS CON$ 1
SYS UET$ 1
SYS PROXY_ROLE_DATA$ 1
SYS OBJ$ 1
SYS IND$ 1
这个不起眼的小问题虽说无伤大雅,但也会给人带来不少困惑。
全文完
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29047826/viewspace-1655805/
,如需转载,请注明出处,否则将追究法律责任。