SQL> 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
SQL> create table t ( id number check (id > 0), name varchar2(10) not null);
SQL> column condition format a30
SQL> select obj#,condition from sys.cdef$ where obj# in (select object_id from dba_objects where wner=user and object_name='T');
OBJ# CONDITION
---------- ------------------------------
101266 "NAME" IS NOT NULL
101266 id > 0
alter system flush shared_pool;
SQL> select sql_text,executions from v$sql where sql_text like 'select condition from cdef$ where rowid=:1%';
no rows selected
begin
for i in 1..1000 loop
execute immediate 'insert into t values(' || i || ',''test'')'; end loop;
end;
/
SQL> column sql_text format a60
SQL> select sql_text,executions from v$sql where sql_text like 'select condition from cdef$ where rowid=:1%';
SQL_TEXT EXECUTIONS
------------------------------------------------------------ ----------
select condition from cdef$ where rowid=:1 1001
select condition from cdef$ where rowid=:1%的executions次数应该不存在变化)!
begin
for i in 1001..2000 loop
execute immediate 'insert into t values(' || i || ',''test'')'; end loop;
end;
/
SQL> select sql_text,executions from v$sql where sql_text like 'select condition from cdef$ where rowid=:1%';
SQL_TEXT EXECUTIONS
------------------------------------------------------------ ----------
select condition from cdef$ where rowid=:1 2001
alter table t add constraint name_is_not_null check (name is not null);
SQL> select obj#,condition from sys.cdef$ where obj# in (select object_id from dba_objects where wner=user and object_name='T');
OBJ# CONDITION
---------- ------------------------------
101266 "NAME" IS NOT NULL
101266 id > 0
101266 name is not NULL
执行如下:
rollback;
begin
for i in 2001..3000 loop
execute immediate 'insert into t values(' || i || ',''test'')'; end loop;
end;
/
SQL> select sql_text,executions from v$sql where sql_text like 'select condition from cdef$ where rowid=:1%';
SQL_TEXT EXECUTIONS
------------------------------------------------------------ ----------
select condition from cdef$ where rowid=:1 4001
SQL> alter session set cursor_sharing = force ;
rollback;
begin
for i in 3001..4000 loop
execute immediate 'insert into t values(' || i || ',''test'')'; end loop;
end;
/
SQL> select sql_text,executions from v$sql where sql_text like 'select condition from cdef$ where rowid=:1%';
SQL_TEXT EXECUTIONS
------------------------------------------------------------ ----------
select condition from cdef$ where rowid=:1 4003
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-737207/ ,如需转载,请注明出处,否则将追究法律责任。