DDL lock on the object in a SELECT statement?

Environment:

Oracle 11.2.0.4 EE on Solaris

My client called me when she was trying to create a new index on a table and the process was just hanging.  Also, she was not able to DELETE an existing index on the same table, which deal with hang them as well.

After reviewing the advice DBA_DDL_LOCKS, I found a DDL lock on the target of the index table.

The DDL lock is held by a process doing a SELECT on the table and this process worked for several hours.

There was no entry in V$ LOCKED_OBJECTS for the table.

I don't know, yet, what other operations prior to the SELECT statement in the offending process, I have not heard of the user yet.

I realize a DDL lock is placed on objects to prevent changes while specific operations are directed against this object, i.e. the DROP, UPDATE, compile the PACKAGE, etc.

Question: Is a select also place a DDL lock on a table at a level that would avoid a new index is created or an existing index having fallen?

Thank you very much for your comments!

Any reference to the resolution is greatly appreciated.

I searched some Concepts Developers Guide, SQL, even Google reference Guide.

-gary

> My question is now, this lock persists for the duration of the running query?

Easy enough to show that it is not.

Session1:

SQL> create table foo(bar number);     

Table created.                         

SQL> insert into foo values(1);       

1 row created.                         

SQL> commit;                           

Commit complete.                       

SQL> variable x refcursor
SQL> variable a number
SQL> begin
  2  open :X for select bar from foo;
  3  end;
  4  /                                 

PL/SQL procedure successfully completed.

Session 2:

SQL> drop table foo;

Table dropped.     

Note that I was able to remove the table even if select is still 'in progress' - the cursor is open.

If you really want to blow your mind, go back to the session 1:

SQL> begin
  2  fetch :X into :a;
  3  end;
  4  /                                

PL/SQL procedure successfully completed.

SQL> print a                          

         A
----------
         1       

The picture has gone, but I can always look for him. However, try again:

SQL> /
begin
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist          

Note that the forum software is stupid. is: followed by x. seems it's really important to have a smiley to lovey eyes in a technical forum.

Edit - and when you format the SQL code, it is removed completely and render invisible... silly.

I edited my code to use: X and the problem disappeared...

Tags: Database

Similar Questions

  • How to loop through the results of a select statement in a process flow?

    Hello

    I use Warehouse Builder 10 g R2.

    I'm trying to implement a loop in a process stream that runs through the results of a select statement.

    In pl/sql, it would be implemented as a for loop by using a slider, but I simply doesn't work how to do this using the loops in the process flow.

    Someone at - it ideas?

    Thank you
    Liffey

    Liffey,
    Look at this thread
    For or while loop a loop in the process flow

    Kind regards
    Oleg

  • locking of the objects before

    Hello

    In my project, I try to lock the cover, when I lock the position it resembles what I have said.

    When I run the VI objects have been moved from the locked position.

    Kind regards

    Hari

    After changing the color of the plot for your selection do a right-click the graph > data operation > do the deafult value... I hope this helps...

  • Find/replace preference - include locked, locked layer the objects (Find only)

    Hi all

    I was wondering if anyone can help, I'm trying to make sure that the option "Include Locked layers and objects locked (research only)" on the box search/replace is active when the script below is executed because when it is disabled the text find/replace does not check locked layers and objects.

    In InDesign this icon located in the Find/Replace dialog box, a little less the "search:" drop down menu, icon of the left hand.

    Replace the text "Page Type"

    app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;

    app.findTextPreferences.findWhat = "Page Type";

    {found = app.activeDocument.findText () [i] = "STET".silence ;}

    Any help would be great thanks, Brendan

    app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;

    app.findChangeTextOptions.includeLockedLayersForFind = true;

    app.findTextPreferences.findWhat = "Page Type";

    {found = app.activeDocument.findText () [i] = "STET".silence ;}

  • normalize the schema of the table in a select statement (without view)

    Hello

    I have a table storing a physical value, mean temperature for different locations every minute. The table schema is as following: timestamp (datetime), rental (string), value (number).

    Do you know a way to have a select statement, return of lines with the following data: timestamp, the value at location1, value of place.2 guests, etc.

    This will help me to create time series in he same diagram in my reporting tool.

    This may be possible with a view, but I don't have access to the database, the best I can do is set my a data source such as a select statement.

    Thank you!

    Brahim

    PS. We use Oracle 10 g R2

    Hello

    8e07ad81-CDAE-4c23-b0fb-b6cd117cf5bc wrote:

    Hello

    I have a table storing a physical value, mean temperature for different locations every minute. The table schema is as following: timestamp (datetime), rental (string), value (number).

    Do you know a way to have a select statement, return of lines with the following data: timestamp, the value at location1, value of place.2 guests, etc.

    This will help me to create time series in he same diagram in my reporting tool.

    This may be possible with a view, but I don't have access to the database, the best I can do is set my a data source such as a select statement.

    Thank you!

    Brahim

    PS. We use Oracle 10 g R2

    What you're asking about is called pivoting.  The ahs Forum FAQ page devoted to this topic: Re: 4. How can I convert rows to columns?

    Since you're using Oracle 10, you cannot use the SELECT... Function PIVOT; You can use GROUP BY and CASE instead.

    Do ' t worry not about creating views.  What you can do with views, you can also do it using a WITH clause in your query.

    If you get stuck, please post some sample data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also to publish the results you want from this data, as well as your best attempt to query a specific question.

    Explain, using specific examples, how you get the results desired from data provided.

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • can I get an exact part of the data in a select statement

    Hi... good afternoon...

    I want to extract the records from a table by the select statement. but I don't want to go as it's the folder. I want to go look for a particular part of the eacg folder in this column.

    for example...

    table_name = tab1
    column_name = col1

    the col1 contains datas as * 'customer research-cs', 'get client-gc', 'customer delete-cd' * etc etc...

    now, while writing the select query, I want to get the descriptive result as get the customer, customer, customer search remove... .that is I don't want the symbols...

    is it possible to achieve this?

    PLSS suggest...

    You mean like these ways to do...

    SQL> ed
    Wrote file afiedt.buf
    
      1* select substr('customer search-cs',1,length('customer search-cs')-3) from dual
    SQL> /
    
    SUBSTR('CUSTOME
    ---------------
    customer search
    
    SQL> ed
    Wrote file afiedt.buf
    
      1* select regexp_substr('customer search-cs','^[^-]*') from dual
    SQL> /
    
    REGEXP_SUBSTR('
    ---------------
    customer search
    
    SQL>
    
  • can we write the function in a select statement?

    I have function and there Out parameter, so in this case I can write a select statement to my function to retrieve the value?

    user11195165 wrote:
    I have function and there Out parameter, so in this case I can write a select statement to my function to retrieve the value?

    Never mind that it's bad! for a function to have an OUT parameter. That's not how the functions should be designed and written.

    It's like with a knife like a spoon to eat porridge. Of course, it can work in a way. But why? A knife was never designed to be a spoon - and while it may work of porridge to eat, you'll have a hell of a time trying to use it to eat the soup. So, use the right tool.

    In other words, a function is the wrong tool for the job. Use a procedure.

  • How to add an imaginary line in the result of the value of a SELECT statement.

    Hello all-

    I have requirment to add an imaginary line in the result set of a SELECT statement.

    For example lets say it is a pay table having the following columns:

    Number of Payment_id
    status varchar2 (10)
    number amount
    date of payment_date

    so here's the data: -.

    Payment_id status amount payment_date
    applied 1 100 12/07/2008
    2 Reversed 200 01 / 06/2009
    Applied 3 300 01 / 07/2009


    Here is my SQL

    Select * form payment where payment_date > = 01/01/2009

    The output will be

    2 Reversed 200 01 / 06/2009
    Applied 3 300 01 / 07/2009

    My desired output is less than

    2 Reversed 200 01 / 06/2009
    Applied 3 300 01 / 07/2009
    reversed-200 2, 01 / 06/2009-(Dummy Row)

    Third line here is the imaginary line that I add when the status is "reversed".

    I would be very grateful for any help on this...

    Thank you
    Gerard

    Cartesion join against a shadow table is a useful method to create a fictitious line:

    with my_tab as (select 1 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
                    select 1 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 1 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/05/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 4 Payment_id, 'Reversed' Status, -400 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 5 Payment_id, 'Applied' Status, 500 Amount, to_date('01/07/2009', 'mm/dd/yyyy') payment_date from dual),
                    --- end of mimicking your table
          dummy as (select 'Reversed' col1, 1 rn from dual union all
                    select 'Reversed' col1, 2 rn from dual)
    select mt.cust_id,
           mt.payment_id,
           mt.status,
           decode(dummy.rn, 2, -1*mt.amount, mt.amount) amount,
           mt.payment_date
    from   my_tab mt,
           dummy
    where  mt.status = dummy.col1 (+)
    order by mt.cust_id, mt.payment_id, dummy.rn nulls first;
    
    CUST_ID     PAYMENT_ID     STATUS     AMOUNT     PAYMENT_DATE
    1     1     Applied     100     07/12/2008
    1     2     Reversed     200     06/01/2009
    1     2     Reversed     -200     06/01/2009
    1     3     Applied     300     06/01/2009
    2     1     Applied     100     07/12/2008
    2     2     Reversed     200     05/01/2009
    2     2     Reversed     -200     05/01/2009
    2     3     Applied     300     06/01/2009
    2     4     Reversed     -400     06/01/2009
    2     4     Reversed     400     06/01/2009
    2     5     Applied     500     07/01/2009
    

    Published by: Boneist on January 7, 2009 23:10
    NB. You may need to mess around with the order if that is not in the order you want. You did not mention what the rules were for all orders expected, so I composed my own * {;-)

    Also, I added a (cust_id) identifier to differentiate different types of payments, as is usually the case. Remove unless it is not applicable to your case.

  • The execution of a select statement

    I want to run a select statement and show extract it result in table view (multiple records) how do?

    Add a button to the form created by my suggestions, create a WHEN-BUTTON-PRESS-trigger for her and the code

    GO_BLOCK('MYBLOCK');
    EXECUTE_QUERY;
    
  • How to pass the number object type to bind the variable in a select statement

    Hello

    I have a scenario like,

    UI, we store the values in the type of object, and this object type must be spent in a select query to retrieve the data accordingly.

    Is it possible to do so.

    If this isn't the case, please let me know how to take the values of object type and pass to the select query.

    Kind regards

    I found it,

    Object_name ('parameters1', 'parameter2');

  • The display area jumps away from the objects that I select

    Hello

    I work in Adobe Captivate 9 and when I Zoom in and click on an object of display area immediately jumps away from the subject.

    For example, if I click on an image in the corner bottom right display area jumps away from this subject and instead shows me the upper left corner of the slide

    I'm doing something wrong?

    Thank you

    SoC

    Loss of concentration and very annoying. Was not the case in CP7. You can also connect a

    bug report, please?

  • the combination of two select statements to increase the maintainability and performance

    Hi SQL Experts,

    I use the Version of Oracle 11g DB and got both of the statements below.

    My mind can´t get his head around it how and if these two can be combined.

    They look like they could, but I can't figure out how... and I don't mean with a UNION ALL operation

    My main goal is a gain in performance and maintainability.

    SELECT *.

    OF T_TEMP_42 T1 WHERE T1. MATRIX_2 IS NULL AND

    (T1. BL_CODE | T1. YASSINE | T1. MATRIX_1 | T1. FIRMTYPE)

    PO NO

    (

    SELECT BL_CODE. YASSINE | MATRIX_1 | FIRMTYPE

    OF T_TEMP_41, WHERE MATRIX_2 IS NULL).

    ------------------------------------------------------------------------------------

    SELECT *.

    OF T_TEMP_42 T1 WHERE T1. MATRIX_2 IS NOT NULL AND

    (T1. BL_CODE | T1. YASSINE | T1. MATRIX_1 | T1. MATRIX_2 | T1. FIRMTYPE)

    PO NO

    (

    SELECT BL_CODE. YASSINE | MATRIX_1 | MATRIX_2 | FIRMTYPE

    OF T_TEMP_41, WHERE MATRIX_2 IS NOT NULL

    );

    Thanks for your suggestions.

    Try this

    SELECT *.

    OF T_TEMP_42 T1

    WHERE (BL_CODE, YASSINE, MATRIX_1, FIRMTYPE, MATRIX_2) NOT IN (SELECT BL_CODE, YASSINE, MATRIX_1, FIRMTYPE, T_TEMP_41 MATRIX_2)

    It came off really simple... maybe too simple

  • Function that returns the results of a select statement

    Hello

    I would like to create a feature on the famous HR Departments oracle table to select * from him. I don't know how to do it.

    Is someone can help me?.

    Thank you

    Oracle stored functions cannot return result sets directly but can return the REF CURSOR. Please read [optimize result set retrieval using ODP.NET and Ref Cursor | http://www.oracle.com/technology/pub/articles/mastering_dotnet_oracle/williams_refcursors.html] which gives complete examples in PL/SQL for the side Server and VB. NET client side.

  • get the ddl of the object in sqlplus

    Hello.

    How to get into the sqlplus to object ddl statement?

    as:

    Select the ddl from dba_objects where object_name = 'my_table ';

    Hello

    You can use the package which is displayed in the posts above else there are alternatives to get the DDL both
    For more than one table. You can go for export and import with Options by which you can get the DDL for all
    the objects in the schema according to your requirement.

    You can go for "dbms_metadata.get_ddl".
    next thing export and import with show options = 'Y '.

    -Pavan Kumar N

  • How to query the DDL lock functions or stored procedures and packages?

    Hello!

    The subject says it all: how to display existing DDL locks on the functions or stored procedures and packages?

    While running a procedure, it cannot be deleted or replaced, so there must be a DDL lock on it. The information does not seem to be in V$ LOCK or V$ LOCKED_OBJECTS.

    Thank you!
    Marcus

    Published by: David on November 21, 2009 15:43

    Hello

    You have the DBA_DDL_LOCKS view.

    Best regards
    Jean Valentine

Maybe you are looking for