Oracle - sql_text truncates to 20 characters for CREATE / ALTER / GRANT statements?

I seem to run into an odd problem where Oracle did not store / return the full SQL for queries. I was tracking the currently active requests, attaching v$session

to v$sqltext

when I noticed that all requests CREATE TABLE ____ AS

had a value sql_text

that was truncated to 20 characters.

For example:

SQL> SELECT sql_text, LENGTH(sql_text), sql_fulltext, LENGTH(sql_fulltext) FROM v$sql WHERE sql_id = 'sql_id_here';

SQL_TEXT                            LENGTH(SQL_TEXT) SQL_FULLTEXT                        LENGTH(SQL_FULLTEXT)
----------------------------------- ---------------- ----------------------------------- --------------------
create table schema.                              20 create table schema.                                  20

1 row selected.


SQL> SELECT sql_text, LENGTH(sql_text) FROM v$sqltext WHERE sql_id = 'sql_id_here';

SQL_TEXT                            LENGTH(SQL_TEXT)
----------------------------------- ----------------
create table schema.                              20

1 row selected.

SQL> SELECT sql_text, LENGTH(sql_text) FROM v$sqltext_with_newlines WHERE sql_id = 'sql_id_here';

SQL_TEXT                            LENGTH(SQL_TEXT)
----------------------------------- ----------------
create table schema.                              20

1 row selected.

      

I thought it might be a separate incident, so I checked all entries CREATE TABLE

in v$sqltext

:

SELECT sql_id, COUNT(*) AS entries, SUM(LENGTH(sql_text)) AS query_len
FROM v$sqltext
WHERE sql_id IN (
    SELECT sql_id
    FROM v$sqltext
    WHERE piece = 0
      AND UPPER(sql_text) LIKE 'CREATE TABLE%'
)
GROUP BY sql_id
ORDER BY 1, 2, 3

      

Of the 250+ sql_id records, all had entries = 1

and query_len = 20

.

However, if I check dba_audit_trail

after the query completes (assuming I know in advance which table is being created) the full sql_text is present here.

What's going on and how can I fix it, so it v$sqltext

contains a full query for operators CREATE TABLE ___ AS

?


Edit: Upon closer inspection, it turns out that all queries are GRANT

, CREATE

and ALTER

truncates to 20 characters in v$sqltext

. All other requests contain full text. I open generosity to hopefully get to the point.

+3


source to share


1 answer


This is similar to a known issue with 11.2.0.4. If you have access to my Oracle support look at bug 19634213; and bugs 18431964, 20308798, and possibly 18245071 (which is not publicly available). I obviously cannot go into details or reproduce what they are saying. From nop77svk's comment, it may have been fixed in 12c, but may also be platform specific.



If this is causing the problem, you need to raise the service request in Oracle to make sure you push the same and know if a patch is available.

+3


source







All Articles