Oracle DDL 语句(如 CTAS),执行后,不显示在 V$SQL

Oracle DDL statment ( like CTAS) , after executed, not show in V$SQL

为什么 Oracle“DDL”语句(如“CTAS”)在执行后没有显示在 V$SQL 视图中? 怎样才能得到“SQL_ID”呢?我想在 SQl 计划基线中使用“SQL_ID”。 TNX

CTAS 操作出现在 v$sql 视图中

SQL> create table t1 as select * from dba_objects ;

Table created.

SQL> select sql_text,sql_id from v$sql where sql_text like '%create table t1 as select%' ;

SQL_TEXT
--------------------------------------------------------------------------------
SQL_ID
-------------
create table t1 as select * from dba_objects
4j5kv6x7cz5r7

select sql_text,sql_id from v$sql where sql_text like '%create table t1 as selec
t%'
5n4xnjkt3vz3h

SQL 计划基线是 SPM 的一部分(SQL 计划管理)

A SQL plan baseline. A plan baseline is a set of accepted plans that the optimizer is allowed to use for a SQL statement. In the typical use case, the database accepts a plan into the plan baseline only after verifying that the plan performs well. In this context, a plan includes all plan-related information (for example, SQL plan identifier, set of hints, bind values, and optimizer environment) that the optimizer needs to reproduce an execution plan.

如果您经常使用 CTAS,我猜您是在批处理模式下进行,因此删除 table 然后使用提到的 CTAS 命令重新创建它。我宁愿尝试查看该语句的 SELECT 本身有什么问题。

但是 SQL 基线更侧重于解决查询,因为优化器并不总是选择最好的计划,因此可以修复和改进计划。

V$SQL 只显示 CATS 的前 20 个字符。这是 Oracle 数据库 11g 中的错误。详情请见:()1.