Is row locking available in Oracle 10g?

Hi,
Does anybody knows if Oracle 10g can do a row locking?
Thanks,
Amorsolo

Teymur Hajiyev wrote:
amorsolo wrote:
Hi,
Does anybody knows if Oracle 10g can do a row locking?
Thanks,
AmorsoloIn my opinion locking mechanism in Oracle is one of the features/option which made Oracle the best in Database world.
Regards,
Teymur Hajiyev
Oracle 10g Certified Master
http://teymur-hajiyev.blogspot.com
http://dba.az
Agree with Teymur. As Tom Kyte said in the "Comparison between Oracle and Others" topic:
For example -- all of the above would get check marks for having "row level locking". Once you look at the implementations however, you'll find they are way different. In Oracle, the overhead of having 1 lock is the same as having 1billion locks (eg: none).
In the others there is a HUGE different between the two as locks are a scare resource in those systems, they consume memory, take up space, are stored in in-memory data structures. Our implementation of the feature is so different as to not be comparable.
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1886476148373

Similar Messages

  • Lock types in oracle 10g with sql examples

    can some body easily in simple words tell some thing about the table locks types in oracle 10g with some sql examples?

    Oracle locking is a complex topic that may not easily be explained with simple words.
    Please try to read above mentioned link starting from simple examples to used lock types. I don't think it's a good idea to "over simplify" the topic starting from the different lock types.
    Another way to explain some lock types can be found in following OTN discussion with Tom Kyte (who is also one of the primary author of Concepts Guide 11.2): TM / TX Locks ( Tom Kyte and Oracle Docu) ; note the different points of view about what is the row lock ...
    Edited by: P. Forstmann on 29 juin 2011 14:00

  • Enq: TX - row lock contention in forms 10g sequency number generation

    Iam Getting the Deadlock issue in oracle formdeveloper 10g database is 11g Acutually in our small Hospital organization using different forms generating entrying labrequest form finally save time
    one sequency number will generated i have give procedure below every save criteria form using below procedure some time iam getting lock iam using blocksession query i have find out some
    OSUSER
    MACHINE
    TERMINAL
    PROGRAM
    SQL_ID
    LOGON_TIME
    BLOCKING_SESSION_STATUS
    BLOCKING_SESSION
    EVENT
    user423
    UMCCDOM\LEVEL4-MICU
    LEVEL4-MICU
    PrjMcr.EXE
    0ccngw7dfkmgb
    23/09/2013 11:34:41 AM
    VALID
    277
    enq: TX - row lock contention
    SYSTEM
    WORKGROUP\PRIAPPSVR
    PRIAPPSVR
    frmweb.exe
    0ccngw7dfkmgb
    23/09/2013 11:32:50 AM
    VALID
    186
    enq: TX - row lock contention
    SYSTEM
    WORKGROUP\PRIAPPSVR
    PRIAPPSVR
    frmweb.exe
    0ccngw7dfkmgb
    22/09/2013 2:49:47 PM
    VALID
    277
    enq: TX - row lock contention
    SYSTEM
    WORKGROUP\PRIAPPSVR
    PRIAPPSVR
    frmweb.exe
    0ccngw7dfkmgb
    23/09/2013 7:00:22 AM
    VALID
    186
    enq: TX - row lock contention
    user290
    UMCCDOM\LEVEL2-N
    LEVEL2-N
    PrjMcr.EXE
    0ccngw7dfkmgb
    23/09/2013 10:28:06 AM
    VALID
    277
    enq: TX - row lock contention
    lock are happen after open the code i have find out used FOR UPDATE in procedure please tell me any alternative for this every labrequest form saving time using this procedure for generating prefix sequence number multiple user using with different systems
    PROCEDURE   Gsp_GenSeqNum (I_SvPrefixCd IN VARCHAR2,I_SvUserName IN VARCHAR2,
                              O_SvSeqNum OUT VARCHAR2) IS
    --This Procedure generates the sequence number
    --by retrieving the prefix based on the code
    --supllied to the procedure.
      CURSOR  crSeqGenerator IS
             SELECT Gsn_prefix_last_num, Gsn_prefix_year
                FROM G_SEQUENCE_NUMBER
             WHERE Gsn_prefix_Cd = I_SvPrefixCd
                   AND Gsn_prefix_year = TO_CHAR(SYSDATE,'YYYY')
      FOR UPDATE OF Gsn_prefix_last_num;
      udSeqNum        G_SEQUENCE_NUMBER.Gsn_Prefix_last_num%TYPE;
      udNextSeqNum    G_SEQUENCE_NUMBER.Gsn_Prefix_last_num%TYPE;
      udYear          G_SEQUENCE_NUMBER.Gsn_Prefix_year%TYPE;
      udPrefix        G_SEQUENCE_PREFIX.Gsp_Prefix_Value%TYPE;
    BEGIN
      SELECT Gsp_Prefix_Value
      INTO udPrefix
      FROM G_SEQUENCE_PREFIX
      WHERE Gsp_Prefix_Cd = I_SvPrefixCd;
      OPEN crSeqGenerator;
      FETCH crSeqGenerator
       INTO udSeqNum,
            udYear;
      IF crSeqGenerator%FOUND THEN
         udNextSeqNum  :=udSeqNum + 1;
         O_SvSeqNum     := udPrefix||'/'||TO_CHAR(SYSDATE,'YY')
                                   ||'/'||LPAD(TO_CHAR(udNextSeqNum),6,'0');
      ELSE
    INSERT INTO G_SEQUENCE_NUMBER VALUES(I_SvPrefixCd,TO_CHAR(SYSDATE,'YYYY'),0,I_SvUserName,SYSDATE);
         udSeqNum      :=0;
         udNextSeqNum  :=udSeqNum + 1;
         O_SvSeqNum:=UdPrefix||'/'||TO_CHAR(SYSDATE,'YY')
                             ||'/'||LPAD(TO_CHAR(udNextSeqNum),6,'0');
      END IF;
      UPDATE G_SEQUENCE_NUMBER
         SET Gsn_Prefix_last_num=udNextSeqNum
       WHERE Gsn_Prefix_Cd = I_SvPrefixCd
         AND Gsn_Prefix_year=TO_CHAR(SYSDATE,'YYYY');
      CLOSE crSeqGenerator;
    END Gsp_GenSeqNum;
    Thanks
    subbu

    This application is inbuit with some modules VB (cath ,cardio)and oracle forms for required sequence number generation different time used this procedure whereever required the sequence Prefix generation.If i replace the procedure sequene to oracle standard sequency if the user cannot save the form unnessary sequency generated order is missing from sequence.

  • Issue with lock file in Oracle 10g app server - MDB not running

    Hi,
    I have Oracle 10g & MQ 6 on my laptop. I generated JNDI bindings for app server-MQ by giving ip address of my machine first. Then i changed it to "localhost" & generated new set of .bindings file.
    With this new set i am able to send messages from my program to a queue. I also have an MDB which should listen to the same queue.
    However now my mdb is not listening to the queue & i suspect it is due to host address change, - because each time i start the server, i see a lock file created "OracleASRouter_store.lock" - under j2ee\home\persistance. And below is the content of the same -
    "O10.1.4.245:/C:/Program Files/Oracle/oc4j_extended_101330/j2ee/home/persistence/"
    As per few suggestions on this site, I deleted this file & restated app server, deleted whole content of persistance folder, restarted app server. But each time i see this file created and also see the ip address in log.xml under j2ee\home\log\oc4j
    Error message in this log.xml file is
    <MESSAGE>
    <HEADER>
    <TSTZ_ORIGINATING>2007-09-19T11:22:35.265-04:00</TSTZ_ORIGINATING>
    <COMPONENT_ID>j2ee</COMPONENT_ID>
    <MSG_ID>J2EE EJB-02009</MSG_ID>
    <MSG_TYPE TYPE="WARNING"></MSG_TYPE>
    <MSG_LEVEL>1</MSG_LEVEL>
    <HOST_ID>IFLEXNY-EXT99</HOST_ID>
    <HOST_NWADDR>10.1.4.245</HOST_NWADDR>
    <MODULE_ID>ejb.runtime</MODULE_ID>
    <THREAD_ID>10</THREAD_ID>
    <USER_ID>chetanmi</USER_ID>
    </HEADER>
    <CORRELATION_DATA>
    <EXEC_CONTEXT_ID><UNIQUE_ID>10.1.4.245:65858:1190215355296:0</UNIQUE_ID><SEQ>0</SEQ></EXEC_CONTEXT_ID>
    </CORRELATION_DATA>
    <PAYLOAD>
    <MSG_TEXT>[STGMQ:STGMQEJB:TestMDB] Unexpected exception by JMS provider: javax.jms.MessageEOFException: initializeConnection.</MSG_TEXT>
    <SUPPL_DETAIL><![CDATA[javax.jms.MessageEOFException: initializeConnection
         at com.evermind.server.jms.JMSUtils.make(JMSUtils.java:1075)
         at com.evermind.server.jms.JMSUtils.toJMSException(JMSUtils.java:1155)
         at com.evermind.server.jms.TCPJMSRemoteServer.initializeConnection(TCPJMSRemoteServer.java:154)
         at com.evermind.server.jms.TCPJMSRemoteServer.initializeConnection(TCPJMSRemoteServer.java:110)
         at com.evermind.server.jms.TCPJMSRemoteServer.<init>(TCPJMSRemoteServer.java:68)
         at com.evermind.server.jms.EvermindConnection.<init>(EvermindConnection.java:122)
         at com.evermind.server.jms.EvermindQueueConnection.<init>(EvermindQueueConnection.java:70)
         at com.evermind.server.jms.EvermindQueueConnectionFactory.unprivileged_createQueueConnection(EvermindQueueConnectionFactory.java:101)
         at com.evermind.server.jms.EvermindQueueConnectionFactory.access$000(EvermindQueueConnectionFactory.java:44)
         at com.evermind.server.jms.EvermindQueueConnectionFactory$1.execute(EvermindQueueConnectionFactory.java:81)
         at com.evermind.server.jms.InContainerProxy.doSecureOp(InContainerProxy.java:157)
         at com.evermind.server.jms.EvermindQueueConnectionFactory.createQueueConnection(EvermindQueueConnectionFactory.java:78)
         at com.evermind.server.jms.EvermindQueueConnectionFactory.createQueueConnection(EvermindQueueConnectionFactory.java:69)
         at com.evermind.server.ejb.MessageDrivenConsumer.createNonXAResources(MessageDrivenConsumer.java:567)
         at com.evermind.server.ejb.MessageDrivenConsumer.initializeJMSResources(MessageDrivenConsumer.java:491)
         at com.evermind.server.ejb.MessageDrivenConsumer.processMessages(MessageDrivenConsumer.java:208)
         at com.evermind.server.ejb.MessageDrivenConsumer.run(MessageDrivenConsumer.java:169)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: java.io.EOFException
         at java.io.DataInputStream.readInt(DataInputStream.java:358)
         at com.evermind.server.jms.JMSRemoteServer.readCheck(JMSRemoteServer.java:678)
         at com.evermind.server.jms.JMSRemoteServer.readProtocol(JMSRemoteServer.java:696)
         at com.evermind.server.jms.TCPJMSRemoteServer.initializeConnection(TCPJMSRemoteServer.java:134)
         ... 16 more
    ]]></SUPPL_DETAIL>
    </PAYLOAD>
    </MESSAGE>
    <MESSAGE>
    <HEADER>
    <TSTZ_ORIGINATING>2007-09-19T11:22:35.312-04:00</TSTZ_ORIGINATING>
    <COMPONENT_ID>j2ee</COMPONENT_ID>
    <MSG_ID>J2EE EJB-02014</MSG_ID>
    <MSG_TYPE TYPE="WARNING"></MSG_TYPE>
    <MSG_LEVEL>1</MSG_LEVEL>
    <HOST_ID>IFLEXNY-EXT99</HOST_ID>
    <HOST_NWADDR>10.1.4.245</HOST_NWADDR>
    <MODULE_ID>ejb.runtime</MODULE_ID>
    <THREAD_ID>10</THREAD_ID>
    <USER_ID>chetanmi</USER_ID>
    </HEADER>
    <CORRELATION_DATA>
    <EXEC_CONTEXT_ID><UNIQUE_ID>10.1.4.245:65858:1190215355296:0</UNIQUE_ID><SEQ>0</SEQ></EXEC_CONTEXT_ID>
    </CORRELATION_DATA>
    <PAYLOAD>
    <MSG_TEXT>[STGMQ:STGMQEJB:TestMDB] All message consumer threads have terminated due to provider errors, stopping MDB.</MSG_TEXT>
    </PAYLOAD>
    </MESSAGE>
    And my MDB is NOT WORKING. Please let me know how to deal with this.
    Your suggestions would be much appreciated.
    Regard,
    Chetan

    Line # 127 is creating a new application object using ApplicationFactory.
    ApplicationFactory aFactory =
    (ApplicationFactory) FactoryFinder.getFactory(
    FactoryFinder.APPLICATION_FACTORY);
    application = aFactory.getApplication();
    The only way that can throw a null pointer is when aFactory is NULL. I really doubt this case because, the same thing is doen in init() of FacesServlet. If it had failed there, the exception should have occured during server startup.
    This leaves me more and more confused....I am desperate for some help now :((
    Ramesh

  • Oracle 9i feature not available in Oracle 10g

    The following query does work in Oracle 9.2.0.4 (and 9.2.0.5), but does not work in Oracle 10.1.0.3 (Linux)
    SELECT *
    FROM MEDIA_CONTENT
    WHERE EXISTSNODE
    (MCON_XML,
    '/rdf:RDF/rdf:Description[ora:contains(dc:title,"Whale")>0]',
    'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ora="http://xmlns.oracle.com/xdb"')
    The error message
    ORA-29913: error in executing contains callout
    ORA-15198: operation [contains with non-leaf node] is not yet available
    indicates, that this feature is not yet available in Oracle 10.1.0.3
    Does anybody know, when this feature is available in Oracle 10, too ? Already in 10.1.0.4 ? Or in Oracle 10g Release 2 ?
    Thanks,
    Ulf

    I assume you have Windows on the client. The "Drivers" page of the ODBC_DSA should list all installed drivers. You require:
    name= Oracle ODBC Driver
    version= 8.01.07.00 (or something similar)
    company= Oracle Corporation DO NOT USE the Microsoft one.
    If this does not show, then either it was not included in the Oracle Client installation or you have not rebooted after the Oracle Client installation; the ODBC driver is not visible until rebooted.

  • How to maintain Data availability in Oracle 10g RAC when LOADING the data?

    Hi
    we are having Oracle 10g server on Sun Solaris(64 bit) with 8 GB RAM.
    We are in need of moving the database to "Oracle 10g RAC". (Real Application Clusters)
    Our doubt is when loading the data into RAC server, will it affect the application?
    coz' we heared that RAC server should be down when we load the data.
    Is this correct?
    If yes, then How to maintain High data availability when we load the data in RAC server?? Please help me.
    Thanks.

    First, is this the same question that a colleague of yours posted in this thread?
    Data Load in RAC
    Second, are other sessions querying the table that you're loading data into? If so, how are you loading the data?
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • ORA-29278: SMTP transient error:421 Service not available on oracle 10g

    HIi,
    I am trying to send e-mails by using PL/Sql procedure . I am using UTL_MAIL/UTL_SMTP on oracle 10g R1 database.
    There is no problem in creating procedure,but when i am doing execution i am getting the mention error.
    I am trying to send mail with attachment as excel file.
    ORA-20001: The following error has occured: ORA-29278: SMTP transient error:
    421 Service not available
    ORA-06512: at "SCOTT.MAIL_ATT_RAW", line 64
    ORA-06512: at line 1
    -----my procedure code------
    CREATE OR REPLACE PROCEDURE mail_att_raw(filename varchar2) AS
    fil BFILE;
    file_len PLS_INTEGER;
    MAX_LINE_WIDTH PLS_INTEGER := 54;
    buf RAW(2100);
    amt BINARY_INTEGER := 2000;
    pos PLS_INTEGER := 1; /* pointer for each piece */
    filepos PLS_INTEGER := 1; /* pointer for the file */
    filenm VARCHAR2(50) := filename; /* binary file attachment */
    data RAW(2100);
    chunks PLS_INTEGER;
    len PLS_INTEGER;
    modulo PLS_INTEGER;
    pieces PLS_INTEGER;
    err_num NUMBER;
    err_msg VARCHAR2(100);
    resultraw RAW(32000);
    BEGIN
    /* Assign the file a handle */
    fil := BFILENAME('BFILE_DIR', filenm);
    /* Get the length of the file in bytes */
    file_len := dbms_lob.getlength(fil);
    /* Get the remainer when we divide by amt */
    modulo := mod(file_len, amt);
    /* How many pieces? */
    pieces := trunc(file_len / amt);if (modulo <> 0) then
    pieces := pieces + 1;end if;/* Open the file */
    dbms_lob.fileopen(fil, dbms_lob.file_readonly);/* Read the first amt into the buffer */
    dbms_lob.read(fil, amt, filepos, buf);/* For each piece of the file . . . */
    FOR i IN 1..pieces LOOP/* Position file pointer for next read */
    filepos := i * amt + 1;/* Calculate remaining file length */
    file_len := file_len - amt;/* Stick the buffer contents into data */
    data := utl_raw.concat(data, buf);/* Calculate the number of chunks in this piece */
    chunks := trunc(utl_raw.length(data) / MAX_LINE_WIDTH);/* Don't want too many chunks */
    IF (i <> pieces) THEN
    chunks := chunks - 1;
    END IF;/* For each chunk in this piece . . . */
    FOR j IN 0..chunks LOOP/* Position ourselves in this piece */
    pos := j * MAX_LINE_WIDTH + 1;/* Is this the last chunk in this piece? */
    IF (j <> chunks) THEN len := MAX_LINE_WIDTH;
    ELSE
    len := utl_raw.length(data) - pos + 1;
    IF (len > MAX_LINE_width) THEN
    len := MAX_LINE_WIDTH;
    END IF;
    END IF;/* If we got something, let's write it */
    IF (len > 0 ) THEN
    resultraw := resultraw || utl_raw.substr(data, pos, len);
    END IF;
    END LOOP;/* Point at the rest of the data buffer */
    IF (pos + len <= utl_raw.length(data)) THEN
    data := utl_raw.substr(data, pos + len);
    ELSE
    data := NULL;
    END IF;/* We're running out of file, only get the rest of it */
    if (file_len < amt and file_len > 0) then
    amt := file_len;
    end if;/* Read the next amount into the buffer */dbms_lob.read(fil, amt, filepos, buf);
    END LOOP;/* Don't forget to close the file */
    dbms_lob.fileclose(fil);
    SYS.UTL_MAIL.SEND_ATTACH_RAW(sender => '[email protected]', recipients => '[email protected]',subject => 'Testmail', message => 'Hallo', attachment => resultraw, att_filename => filename);
    EXCEPTION
    WHEN OTHERS THEN--dbms_output.put_line('Fehler');
    raise_application_error(-20001,'The following error has occured: ' || sqlerrm);
    END;
    Please suggest me what settings i need to change. This same procedure is running on another maching,but not on my machine.
    If somebody is having any other simple procedure ,please help me.
    My SMTP port -25
    Thanks in advance.

    Hi Justin,
    Please get the answers of your queries
    The error you're getting is coming from the SMTP server you are trying to connect to.
    - What SMTP server is your database configured to use?
    Reply - I am using IIS(5.0)
    - What SMTP server is the database where this code is working configured to use?
    Reply - Same IIS. Database is installed locally on my machine only. I am trying to send mail locally to me only,Not to the outside person.
    - Has the SMTP server been configured to allow connections from both machines?
    Reply - Yes
    One more query, do we really require to set the SMTP_OUT_SERVER parameter for SCOPE=BOTH
    ALTER SYSTEM SET smtp_out_server = '172.16.1.10' SCOPE=BOTH
    I am not able to set like this for BOTH,only for SPFILE i can set ?.
    My SMTP Server IP=172.16.1.10
    PORT- 25
    Thanks
    Manoj

  • Is there a better interface available for Oracle 10g Express?

    Dear Experts
    I just installed Oracle 10g Express for a trial to develop and Accounting ERP. Until now i have been using MS SQL Server 7.0 & 2000 on VB but now we are considering JAVA and want to get the feel of Oracle. My questions are as follows:
    1. Is there a better inteface available other than the Internet Explorer?
    2. Would a better interface be avaliable in other version of Oracle 10g?
    3. Does Oracle have interface to create relationships graphically?
    4. Is there documentation available for 10g in one bundle like the Sybase Adaptive server anywhere or MS Books online?
    5. This is really an excellent forum and i have seen some of the answers and they are great.
    Thanks a lot i hope i will be successfully be able to develop an application using Java (desktop version using swing)and Oracle 10g
    Regards
    Manish Sawjiani

    Standman--
    If you want a somewhat more powerful tool (albeit more complicated) check out TOra:
    http://sourceforge.net/projects/tora/
    As an Oracle DBA I've used this at client's sites when I can't pay for PL/SQL Developer to be installed, and it has quite a few useful things built into it. I think that it's going to see a boom in popularity now that Oracle came out with XE.
    ~Jer

  • What replication methods are available in Oracle 10g Standard Edition?

    Hi All,
    Our customer wants to have two identical servers at two different sites (Virginia and Utah). Server in Virginia will be the primary and the other one will be Standby. Application will run on the primary database and they would like to be able to use the Utah server (standby) in the event of a failure. The switch over can be manual or automated and does not have to be instantaneous.
    I know these things can be in Enterprise Edition, but the cost is an issue here, so I was wondering what other methods are available to achieve this goal with Standard Edition database running on Windows Server 2008?
    Thank you,
    Sinan

    Spajdy,
    According to the Data Guard documentation:
    Getting Started with Data Guard
    "Oracle Data Guard is available only as a feature of Oracle Database Enterprise Edition. It is not available with Oracle Database Standard Edition."
    Unfortunately, the cost is a concern. I would love to be able to use just the Enterprise Edition and Golden Gate or Data Guard, but it is not possible, so my manager says I have to do what I have to do with the Standard Edition.
    Thanks,
    Sinan

  • CPU & I/O quotas available in Oracle 10g ?

    Im a developer.
    I wanted to create 2 schemas so that they will not interfere with each other.
    I wanted to also make sure that the load/activities on one of the schema does not affect the performance of the other.
    Is there anything equivalent of "quotas" in oracle so that the schema ( and teh associated users ) will not consume more than 40% of the CPU and I/O if the quota is set at 40%
    Thanks

    Setting CPU_PER_CALL, CPU_PER_SESSION, LOGICAL_IO_PER_CALL, and LOGICAL_IO_PER_SESSION in a profile, though, will not prevent one user from executing a large enough quantity of SQL in a short enough period of time (either in a single session or in multiple sessions) to use up nearly all of the available hardware resources.
    Assuming you have the enterprise edition, you would probably want to use [Resource Manager|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/mgmt_db.htm#sthref2259]. That would allow you to prioritize the various users in the database and grant one user (or group of users) just 40% of the total CPU if CPU was near 100% (if there are still spare CPU cycles, Oracle would allow those users to use more than 40%)
    Justin

  • Row chaining issue in Oracle 10g

    Hello All,
    I was seeing row chaining issue in one of our production DB. Row chaining was present in all tables having LONG RAW columns.
    As of now I am not supposed to change these to BLOB/CLOB, so I did exp/imp to solve the issue. However, we are repeating this excercise once every quarter, and now it is time we put a permanent fix to it.
    One of such tables has below storage parameters:
    PCTUSED    0
    PCTFREE    10
    INITRANS   1
    MAXTRANS   255
    STORAGE    (
                INITIAL          40K
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
               )Can I be advised what would be the tuning options in above? Note: All of these tables are in GB's.
    For any inputs, please let me know.
    Thanks,
    Suddhasatwa

    SELECT table_name,
           Round(( blocks * 8 ) / 1024 / 1024, 2)
           "Physical Size (GB)",
           Round(( num_rows * avg_row_len / 1024 / 1024 / 1024 ), 2)
           "Actual Size (GB)",
           ( Round(( blocks * 8 ) / 1024 / 1024, 2) - Round((
             num_rows * avg_row_len / 1024 / 1024 / 1024 ), 2) )
           "Wasted Space (GB)"
    FROM   dba_tables
    WHERE  owner = 'SYSADM'
           AND ( Round(( blocks * 8 ) / 1024, 2) - Round(
                     ( num_rows * avg_row_len / 1024 / 1024 )
                                                       , 2) ) > 20
           AND table_name IN (SELECT table_name
                              FROM   dba_tab_columns
                              WHERE  data_type IN ( 'RAW', 'LONG RAW', 'LONG' ))
           AND table_name IN (SELECT table_name
                              FROM   dba_tab_columns
                              WHERE  data_type LIKE '%LONG%')
    ORDER  BY ( Round(( blocks * 8 ) / 1024, 2) - Round(
                          ( num_rows * avg_row_len / 1024 / 1024 )
                                                            , 2) ) DESC; is the air inside the gas tank on your car considered "Wasted Space"?
    would you car run any better if the size of the gas tank got reduced as gasoline was consumed?
    Realize & understand that Oracle & does reused FREE SPACE without any manual intervention.
    It appears you suffer from Complusive Tuning Disorder!

  • Converting Rows into Column in Oracle 10g

    Hi All,                    
    I m using Oracle Version 10.1.0.2.0 - Production                    
    I have requirement to convert rows into column wise as per the following:                    
    My Query is:                    
    WITH t                    
    AS ( SELECT 'A' AS x, 100 AS y FROM DUAL                     
    UNION ALL                    
    SELECT 'B',200 FROM DUAL                    
    SELECT X, Y                    
    FROM t;     
    X Y
    A 100
    B 200
    My Requirement is
    A B
    100 200
    So any one could help me that how I resolve this.
    Regards,
    Prasanta

    Dear frank,
    Thanks for your support,.
    It's working fine for static cases.If the first column is dynamic then how come i will resolve it.
    Example:
    Create table mytab (ID_C Varchar2(15),Value_N Number);
    Records Population into MyTab table is dynamic.
    Insert into mytab values('HO',5000);
    Insert Into mytab values('PG1',2400);
    Insert Into mytab values('PG2',3000);
    Insert Into mytab values('PG3',800);
    Commit;
    SQL> Select * From MyTab;
    IDC_ ValueN_
    HO 5000
    PG1 2400
    PG2 3000
    PG3 800
    Then My expected result will be as follows
    HO PG1 PG2 PG3
    5000 2400 3000 800
    Thanks and Regards,
    Prasanta

  • Pivoting rows into columns in Oracle 10g

    Hi,
    I want to pivot rows into column in some optimal way.
    I don't want to go with the DECODE option as the number of columns can be more than 200.
    i have also tried the transpose logic which is making the pl/sql block too huge.
    can i directly query the database for the desired output instead of storing the data into some arrays and displaying rows as columns?

    Hi,
    Here's a dynamic way to do this is Oracle 10, using theSQL*Plus @ command to handle the dynamic parts.
    First, let's see how we would do this using a static query:
    WITH     col_cntr    AS
         SELECT     column_name
         FROM     all_tab_columns
         WHERE     owner          = 'FKULASH'
         AND     table_name     = 'TEST_EMP'
         AND     column_name     NOT IN ('EMP_ID', 'TYPE_VAL')
    ,     unpivoted_data     AS
         SELECT     e.type_val
         ,     c.column_name
         ,     CASE c.column_name
                  WHEN  'X_AMT'  THEN  x_amt     -- *****  Dynamic section 1  *****
                  WHEN  'Y_AMT'  THEN  y_amt     -- *****  Dynamic section 1  *****
                  WHEN  'Z_AMT'  THEN  z_amt     -- *****  Dynamic section 1  *****
              END     AS v
         FROM          test_emp  e
         CROSS JOIN     col_cntr  c
    SELECT       column_name     AS type_val
    ,       SUM (CASE WHEN type_val = 'Q1' THEN v ELSE 0 END)     AS q1     -- ***** Dynamic section 2  *****
    ,       SUM (CASE WHEN type_val = 'Q2' THEN v ELSE 0 END)     AS q2     -- ***** Dynamic section 2  *****
    ,       SUM (CASE WHEN type_val = 'Q3' THEN v ELSE 0 END)     AS q3     -- ***** Dynamic section 2  *****
    ,       SUM (CASE WHEN type_val = 'Q4' THEN v ELSE 0 END)     AS q4     -- ***** Dynamic section 2  *****
    FROM       unpivoted_data
    GROUP BY  column_name
    ORDER BY  column_name
    ;Column names are hard-coded in two places:
    (1) in the sub-query unpivoted_data, we had to know that there were 3 columns to be unpivoted, and that they were called x_amt, y_amt and z_amt. You want to derive all of that from all_tab_columns.
    (2) in the main query, we had to know that there would be 4 pivoted columns in the rsult set, and that they would be called q1, q2, q3 and q4. You want to derive all that from the data actually in test_emp.
    Instead of hard-coding those 2 dynamic sections, have Preliminary Queries write them for you, a split second before you run the main query, by running this script:
    --  Before writing sub-scripts, turn off features designed for human readers
    SET     FEEDBACK    OFF
    SET     PAGESIZE    0
    PROMPT *****  Preliminary Query 1  *****
    SPOOL     c:\temp\sub_script_1.sql
    SELECT    '              WHEN  '''
    ||       column_name
    ||       '''  THEN  '
    ||       LOWER (column_name)     AS txt
    FROM       all_tab_columns
    WHERE       owner          = 'FKULASH'
    AND       table_name     = 'TEST_EMP'
    AND       column_name     NOT IN ('EMP_ID', 'TYPE_VAL')
    ORDER BY  column_name
    SPOOL     OFF
    PROMPT     *****  Preliminary Query 2  *****
    SPOOL     c:\temp\sub_script_2.sql
    SELECT DISTINCT  ',       SUM (CASE WHEN type_val = '''
    ||                type_val
    ||           ''' THEN v ELSE 0 END)     AS '
    ||           LOWER (type_val)          AS txt
    FROM           test_emp
    ORDER BY      txt
    SPOOL     OFF
    --  After writing sub-scripts, turn on features designed for human readers
    SET     FEEDBACK    5
    SET     PAGESIZE    50
    -- Main Query:
    WITH     col_cntr    AS
         SELECT     column_name
         FROM     all_tab_columns
         WHERE     owner          = 'FKULASH'
         AND     table_name     = 'TEST_EMP'
         AND     column_name     NOT IN ('EMP_ID', 'TYPE_VAL')
    ,     unpivoted_data     AS
         SELECT     e.type_val
         ,     c.column_name
         ,     CASE c.column_name
                  @c:\temp\sub_script_1
              END     AS v
         FROM          test_emp  e
         CROSS JOIN     col_cntr  c
    SELECT       column_name     AS type_val
    @c:\temp\sub_script_2
    FROM       unpivoted_data
    GROUP BY  column_name
    ORDER BY  column_name
    ;As you can see, the main query looks exactly like the static query, except that the two dynamic sections have been replaced by sub-scripts. These 2 sub-scripts are written by 2 prelimiary queries, right before the main query.
    As others have said, the fact that you're asking this question hints at a poor table design. Perhaps the table should be permanently stored in a form pretty much like unpivoted_data, above. When you need to display it with columns x_amt, y_amt, ..., then pivot it, using GROUP BY type_col. When you need to display it with columns q1, q2, ..., then pivot it using GROUP BY column_name.

  • How to check Locking sessions in oracle 10g

    Hi,
    I have tried to get locking sessions. i got the blocking session by using v$lock view.
    Pls help how to get locking sessions.
    Regards,
    Venkat

    Hi Venkat
    Or just run this independent of database version
    select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0  and a.id1=b.id1 and a.id2=b.id2;You can extend this query to find the username and machine (plus all other details) from v$session using the a.sid and b.sid from above
    To find the blocking session_
    SELECT S.SID, S.SQL_ID, S.USERNAME, S.MACHINE from
    V$SESSION S WHERE S.SID  = (SELECT blocker from
    (select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0  and a.id1=b.id1 and a.id2=b.id2
    *_To find the blocked session_*SELECT S.SID, S.SQL_ID, S.USERNAME, S.MACHINE from
    V$SESSION S WHERE S.SID = (SELECT blockee from
    (select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0 and a.id1=b.id1 and a.id2=b.id2
    Edited : Added blocker and blockee code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ROW TO COLUMN in Oracle 10G

    Hi all,
    I have requirement to display the values in a single column base upon the empid
    ex:
    select * from emp where empid=1000
    then actual result will come as
    empid mgr dept sal
    1000 10    10    1000
    1000 20    20    2000
    2000 10   10    1500
    2000 20   20    3000but i want the result in the below format
    for empid 1000 the result will show as
    empid mgr dept sal    mgr2 dept2 sal2
    1000 10    10   1000 20    20    2000
    2000 10   10    1500 20   20    3000Can anyone help me out to achieve this?
    Cheers,
    San

    something like this
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2  (
      3  select 1000 empid, 10 mgr,    10 dept,    1000 sal from dual union all
      4  select 1000, 20,    20 ,   2000 from dual union all
      5  select 2000 ,10 ,  10   , 1500  from dual union all
      6  select 2000 ,20  , 20    ,3000 from dual
      7  )
      8  select empid,
      9  max(decode(mgr,10,mgr)) mgr1,
    10  max(decode(mgr,20,mgr)) mgr2,
    11  max(decode(dept,10,dept)) dept1,
    12  max(decode(dept,20,dept)) dept2,
    13  max(decode(mgr,10,sal)) sal1,
    14  max(decode(mgr,20,sal)) sal2
    15  from t
    16* group by empid
    SQL> /
         EMPID       MGR1       MGR2      DEPT1      DEPT2       SAL1       SAL2
          1000         10         20         10         20       1000       2000
          2000         10         20         10         20       1500       3000

Maybe you are looking for