[20160311]ora-01732.txt

简介: [20160311]ora-01732.txt --今天工作出现ora-01732错误,做一个测试例子,做一个记录: 1.环境: SCOTT@test01p> @ ver1 PORT_STRING          VERSION     BANNER    ...
[20160311]ora-01732.txt

--今天工作出现ora-01732错误,做一个测试例子,做一个记录:

1.环境:

SCOTT@test01p> @ ver1

PORT_STRING          VERSION     BANNER                                                                        CON_ID
-------------------- ----------- ----------------------------------------------------------------------------- ------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0  Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production       0

SCOTT@test01p> create table dept2 as select * from dept ;
Table created.

2.测试:
SCOTT@test01p> delete from (select * from dept2 where rownum=1);
delete from (select * from dept2 where rownum=1)
            *
ERROR at line 1:
ORA-01732: data manipulation operation not legal on this view

D:\tools\rlwrap>oerr ora 1732
oerr ora 1732
01732, 00000, "data manipulation operation not legal on this view"
// *Cause:
// *Action:

--我操作的对象是表,不是视图啊,为什么呢?

3.但是如果你查询如下:
SCOTT@test01p> select *  from (select * from dept2 where rownum=1);
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  d8c0y9masj9g5, child number 0
-------------------------------------
select *  from (select * from dept2 where rownum=1)
Plan hash value: 1094723229
------------------------------------------------------------------------------
| Id  | Operation           | Name  | E-Rows |E-Bytes| Cost (%CPU)| E-Time   |
------------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |       |        |       |     2 (100)|          |
|   1 |  VIEW               |       |      1 |    30 |     2   (0)| 00:00:01 |
|*  2 |   COUNT STOPKEY     |       |        |       |            |          |
|   3 |    TABLE ACCESS FULL| DEPT2 |      1 |    20 |     2   (0)| 00:00:01 |
------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$2 / from$_subquery$_001@SEL$1
   2 - SEL$2
   3 - SEL$2 / DEPT2@SEL$2
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter(ROWNUM=1)

--可以注意ID=1,已经转换为视图.如果这样写:

SCOTT@test01p> select *  from (select * from dept2 ) where rownum=1;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  4zkrhx0q6g68j, child number 0
-------------------------------------
select *  from (select * from dept2 ) where rownum=1
Plan hash value: 2935958459
-----------------------------------------------------------------------------
| Id  | Operation          | Name  | E-Rows |E-Bytes| Cost (%CPU)| E-Time   |
-----------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |       |        |       |     2 (100)|          |
|*  1 |  COUNT STOPKEY     |       |        |       |            |          |
|   2 |   TABLE ACCESS FULL| DEPT2 |      1 |    20 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$F5BB74E1
   2 - SEL$F5BB74E1 / DEPT2@SEL$2
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter(ROWNUM=1)

--知道这些就明白什么回事了.写成如下:

SCOTT@test01p> update (select * from dept2 ) set dname='cccc' where rownum=1;
1 row updated.

SCOTT@test01p> select * from dept2;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 cccc           NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     DALLAS

SCOTT@test01p> rollback ;
Rollback complete.

目录
相关文章
|
Oracle 关系型数据库
[20180502]ORA-01580.txt
[20180502]ORA-01580.txt RMAN> backup current controlfile; Starting backup at 2018-05-02 15:36:03 using channel ORA_DISK_1 using...
1174 0
|
关系型数据库 Oracle Linux
[20180321]ORA-08180.txt
[20180321]ORA-08180.txt $ oerr ora 08180 08180, 00000, "no snapshot found based on specified time" // *Cause: Could not match the time to an SCN from the mapping table.
1297 0
|
Oracle 关系型数据库 Linux
|
Oracle 关系型数据库 数据库
[20171208]ORA-16014(10G).txt
[20171208]ORA-16014(10G).txt --//别人配置dg遇到的问题,当时没有记录.在自己的环境做一个演示.这个问题相对隐藏很深.主要是自己不注意这些细节.
1201 0
|
关系型数据库 Oracle Linux
[20170628]12C ORA-54032.txt
[20170628]12C ORA-54032.txt https://hourim.wordpress.com/2017/06/24/ora-54032-column-to-be-renamed-is-used-in-a-virtual-column-expres...
1460 0
|
SQL 网络协议 Oracle
[20170419]ora-28547.txt
[20170419]ora-28547.txt --//测试环境,莫名奇妙使用toad登陆出现如下错误(使用ezconnect方式)。 ORA-28547: connection to server failed, probable Oracle Net adm...
1412 0
[20160623]ora-00445.txt
[20160623]ora-00445.txt Wed Jun 22 07:38:25 2016 Errors in file e:\app\administrator\diag\rdbms\orcl\orcl\trace\orcl_smco_3976.
1323 0
|
SQL Oracle 关系型数据库
[20151215]ORA-60014.txt
[20151215]ORA-60014: invalid MAXSIZE storage option value.txt SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        ...
846 0
|
SQL
[20150707]ORA-00932.txt
[20150707]ORA-00932: inconsistent datatypes: expected - got CLOB.txt --自己写一个通过sql_id查看sql语句的脚本: column sqltext format a200 sele...
777 0
|
Oracle 关系型数据库 数据库
[20150529]ORA-16664.txt
[20150529]ORA-16664.txt --今天在例行检查中.执行 dgmgrl 出现ora-16664错误. --检查drcdbcn1.log文件,发现如下错误.
996 0