BLOCKING_SESSION column of v$session in 10g

Hi. all.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2088.htm#REFRN30223
what does BLOCKING_SESSION column mean?
For example,
SID Blocking_session
500 400
In the above case,
SID 400 is blocking SID 500 ?
or
SID 500 is blocking SID 400?
Thanks and Regards.

Dear Yas.
Thanks for your confirmation.
Best Regards.

Similar Messages

  • Columns Display Support in Oracle 10g Express Edition..................

    I am working with the Oracle 10g Express Edition, and I Created a Table with 52 Fields and even successfully inserted data into the table via Java Program. But the problem is when I am displaying the table from the Oracle 10g Express Edition Interface, it is displaying only first 31 Fields and displaying "<div class="fielddata">First 31 columns displayed.</div>". What should i do if I want to display all the 52 columns. Awaiting for the Reply. Thank You..

    duplicate post
    Columns Display Support in Oracle 10g Express Edition..................

  • Columns to rows in oracle 10g

    Hi,
      I need the output from columns to rows in oracle 10g.
    this is my original output using some select query,
    select a.created_by,b.modified_by from created_tp a,modified_tp b where a.col_id=b.col_id.
    created_by       modified_by
    Siva                 Raja
    but i need this same output by rows like
    user--anything fine
    Siva
    Raja
    Thanks
    Siva

    Hi,
    select case l when 1 then a.created_by
    else b.modified end
    from created_tp a,modified_tp b, (select level l from dual connect by level <= 2)
    where a.col_id=b.col_id.

  • COMMAND column in V$SESSION table

    Is there any table which stores all the meaning of various values that can be stored in COMMAND column of V$SESSION table
    Like 3 is for SELECT and 47 for Execute, I found some documentation in data dictionary but was wondering if there is some table that can be used when a trigger or procedure is running to pull the values on the fly.
    Thx

    You can find the various values for V$SESSION.COMMAND in Table 7-5 COMMAND Column of V$SESSION and Corresponding Commands found in the link below to build your own table.
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2088.htm#sthref3985

  • COMMAND column in V$SESSION just show s SELECT

    Hi,
    i queried command column in v$session, but it shows only 3(which is for SELECT) and 0 (which is for unknown), even i update some thing its not shown.
    Thanks

    Hi Pavan,
    following is the list for that
    Number     Command     Number     Command
    1     CREATE TABLE     2     INSERT
    3     SELECT     4     CREATE CLUSTER
    5     ALTER CLUSTER     6     UPDATE
    7     DELETE     8     DROP CLUSTER
    9     CREATE INDEX     10     DROP INDEX
    11     ALTER INDEX     12     DROP TABLE
    13     CREATE SEQUENCE     14     ALTER SEQUENCE
    15     ALTER TABLE     16     DROP SEQUENCE
    17     GRANT OBJECT     18     REVOKE OBJECT
    19     CREATE SYNONYM     20     DROP SYNONYM
    21     CREATE VIEW     22     DROP VIEW
    23     VALIDATE INDEX     24     CREATE PROCEDURE
    25     ALTER PROCEDURE     26     LOCK
    27     NO-OP     28     RENAME
    29     COMMENT     30     AUDIT OBJECT
    31     NOAUDIT OBJECT     32     CREATE DATABASE LINK
    33     DROP DATABASE LINK     34     CREATE DATABASE
    35     ALTER DATABASE     36     CREATE ROLLBACK SEG
    37     ALTER ROLLBACK SEG     38     DROP ROLLBACK SEG
    39     CREATE TABLESPACE     40     ALTER TABLESPACE
    41     DROP TABLESPACE     42     ALTER SESSION
    43     ALTER USER     44     COMMIT
    45     ROLLBACK     46     SAVEPOINT
    47     PL/SQL EXECUTE     48     SET TRANSACTION
    49     ALTER SYSTEM     50     EXPLAIN
    51     CREATE USER     52     CREATE ROLE
    53     DROP USER     54     DROP ROLE
    55     SET ROLE     56     CREATE SCHEMA
    57     CREATE CONTROL FILE     59     CREATE TRIGGER
    60     ALTER TRIGGER     61     DROP TRIGGER
    62     ANALYZE TABLE     63     ANALYZE INDEX
    64     ANALYZE CLUSTER     65     CREATE PROFILE
    66     DROP PROFILE     67     ALTER PROFILE
    68     DROP PROCEDURE     70     ALTER RESOURCE COST
    71     CREATE MATERIALIZED VIEW LOG     72     ALTER MATERIALIZED VIEW LOG
    73     DROP MATERIALIZED VIEW LOG     74     CREATE MATERIALIZED VIEW
    75     ALTER MATERIALIZED VIEW     76     DROP MATERIALIZED VIEW
    77     CREATE TYPE     78     DROP TYPE
    79     ALTER ROLE     80     ALTER TYPE
    81     CREATE TYPE BODY     82     ALTER TYPE BODY
    83     DROP TYPE BODY     84     DROP LIBRARY
    85     TRUNCATE TABLE     86     TRUNCATE CLUSTER
    91     CREATE FUNCTION     92     ALTER FUNCTION
    93     DROP FUNCTION     94     CREATE PACKAGE
    95     ALTER PACKAGE     96     DROP PACKAGE
    97     CREATE PACKAGE BODY     98     ALTER PACKAGE BODY
    99     DROP PACKAGE BODY     100     LOGON
    101     LOGOFF     102     LOGOFF BY CLEANUP
    103     SESSION REC     104     SYSTEM AUDIT
    105     SYSTEM NOAUDIT     106     AUDIT DEFAULT
    107     NOAUDIT DEFAULT     108     SYSTEM GRANT
    109     SYSTEM REVOKE     110     CREATE PUBLIC SYNONYM
    111     DROP PUBLIC SYNONYM     112     CREATE PUBLIC DATABASE LINK
    113     DROP PUBLIC DATABASE LINK     114     GRANT ROLE
    115     REVOKE ROLE     116     EXECUTE PROCEDURE
    117     USER COMMENT     118     ENABLE TRIGGER
    119     DISABLE TRIGGER     120     ENABLE ALL TRIGGERS
    121     DISABLE ALL TRIGGERS     122     NETWORK ERROR
    123     EXECUTE TYPE     157     CREATE DIRECTORY
    158     DROP DIRECTORY     159     CREATE LIBRARY
    160     CREATE JAVA     161     ALTER JAVA
    162     DROP JAVA     163     CREATE OPERATOR
    164     CREATE INDEXTYPE     165     DROP INDEXTYPE
    167     DROP OPERATOR     168     ASSOCIATE STATISTICS
    169     DISASSOCIATE STATISTICS     170     CALL METHOD
    171     CREATE SUMMARY     172     ALTER SUMMARY
    173     DROP SUMMARY     174     CREATE DIMENSION
    175     ALTER DIMENSION     176     DROP DIMENSION
    177     CREATE CONTEXT     178     DROP CONTEXT
    179     ALTER OUTLINE     180     CREATE OUTLINE
    181     DROP OUTLINE     182     UPDATE INDEXES
    183     ALTER OPERATOR

  • How to interprete P* value of v$session in 10g??( event=library cache lock)

    Hi, all.
    The database is 2 node RAC (10.2.0.2.0) on 32-bit windows 2003 EE SP1.
    One session on Node 2 is waiting for "library cache lock" to be released
    for "178874" seconds.
    The detail for the session is as follows:
    SID : 444
    TYPE : USER
    PROGRAM : ORACLE.EXE(J001)
    MODULE : EM_PING
    EVENT : library cache lock ▲
    WAIT_CLASS : Concurrency
    P1TEXT : handle address ▲
    P1 : 1206060532 ▲
    P1RAW : 47E305F4 ▲
    P2TEXT : lock address ▲
    P2 : 1108075084 ▲
    P2RAW : 420BE24C ▲
    P3TEXT : 100*mode+namespace ▲
    P3 : 301 ▲
    P3RAW : 0000012D ▲
    WAIT_IN_SECONDS : 178874
    BLOCKING_SESSION : <-- NONE
    There is no blocking session in v$lock.
    Could you teach me how to interprete P* value of v$session in case of "library cache lock"??
    Thanks and Regards.

    Dear user449027.
    Thanks for your reply.
    column wevent format a20
    column bevent format a20
    select
    waiter.sid waiter,
    waiter.p1raw wlockp1,
    waiter.event wevent,
    blocker_event.sid blocker,
    blocker_event.event bevent
    from
    x$kglpn p,
    gv$session blocker_session,
    gv$session_wait waiter,
    gv$session_wait blocker_event
    where
    p.kglpnuse=blocker_session.saddr and
    p.kglpnhdl=waiter.p1raw and
    (waiter.event like 'library cache lock' ) and
    blocker_event.sid=blocker_session.sid
    order by
    waiter.p1raw,waiter.sid
    returns NO rows.
    The database is 2 Node RAC db.
    Do both instances share "x$kglpn"??
    On Node2, sid=444 session is waiting for library cache lock.
    I issued the following script.
    select kglnaobj, kgllkreq
    from x$kgllk x , v$session s
    where s.saddr = x.kgllkses
    and x.kgllkhdl=s.p1raw
    and s.sid = 444;
    KGLNAOBJ KGLLKREQ
    MGMT_JOB_EXEC_SUMMARY 2
    The owner of MGMT_JOB_EXEC_SUMMARY is sysman.
    And MGMT_JOB_EXEC_SUMMARY is valid.
    I issued "DESC MGMT_JOB_EXEC_SUMMARY".
    "DESC MGMT_JOB_EXEC_SUMMARY" hangs.
    The sid=444 session is waiting for almost 2 days.
    I stopped dbconsole and emagent.
    Thanks and Regards.

  • About the last_call_et column in v$session

    Hello,
    Can someone help me about a behaviour that is very strange ...
    We have connection about SAS on a database which manipulate Oracle table and others SAS Structure.
    The query is a "join" about that table and a "SAS Table" between million of lines in the Oracle table one ....
    It last a long time ....
    During the query, we have time to see at the v$session table...
    At any time (it lasts 3h), we saw that the column 'last_call_et' of the v$session never change : it continuesly stay at 0.
    What does it mean ? it means that SAS send a query every second ? Or this column shows the last "internal call"?
    If this is the right reason, i would'nt understand why, when i take the same query( launched by SAS) in TOAD, there is no the same behaviour and this behaviuor is in that case the right behaviour : the session is ACTIVE but the last_call_et respresents really the time since i launched the query... So why when SAS do it, the last_call_et stay at 0 ? it works like SAS launch every second this query !!!!
    Can someone help me ?
    Thanks ...

    Jonathan Lewis wrote:
    user12046632 wrote:
    When you say :
    A FETCH is a database call :
    That means that it must affect the value of 'last_call_et' or not ?"A Fetch is a database call"
    "last_call_et" -- certainly sounds like that could be something to do with database calls, perhaps End Time of LAST database CALL.
    A parse is also a database call, as is an execute ... I feel that perhaps I was a little too concise with my description. You asked why SAS could be doing lots of calls (although that wasn't exactly how you put the question) and I replied that calls could include fetches. And yes, the last_call_et is reset on every fetch (amongst other things - and ignoring the special behaviour of background processes).Ok
    >
    (accordint to me, only to user's activity do so and not to "database internal callsl") ! isn't it ?You don't want to believe everything you read on the internet - even if it did come from the online manuals. But a "fetch" is not a "database internal call" anyway, it's a call from a client to the server.Be sure that i don't do so.
    But the explanation of Oracle of the term 'cal' is not so precise at all ...
    >
    Your follonwing explanations seems to answers contrarily ....
    But the question is there : what sort of call affetcs the value of "last_call_et"All database calls - which you should read as "all calls from the client to the server".Ok
    >
    >>
    >>
    When you say
    all_rows plan => parse call, execute call ..... with very long call time, lots of fetch calls
    first_rows_n plan => parse call, execute call ... with very short call time, lots of fetch calls
    In the first case you would see last_call_et constantly growing until the fetches started
    In the second case last_call_et would keep resetting to zero so fast you probably wouldn't see it as a non-zero value.
    I don't understand : ok for the conséquences on the timing ... but if there are a lot of fetch call in both cases : the behaviour on the 'last_call_et' has to be equal ?True - but in one case I've included an execute call that is active for a very long time, and in the other I've proposed an execute call that is active for a very short time. (And execute calls are calls, and I did ask you about the exact details of your observations.)Ok
    If we consider that every call reset to 0 the value of 'last_call_et',
    why, in the case of launching the same request by TOAD, shouldn't i see the reset to 0 when the fetches works (because in TOAD during the whole query, which means since the click on "launching query" to the retrieving of data, the value did not reset to 0) ?
    >
    >>
    When you say
    Having said that, I've just run a quick test in SQL*Plus on 11.1.0.6 and 10.2.0.3 to demonstrate this point, and 11g is behaving differently from 10g - in the case where the last_call_et should be growing it stays at zero.
    "in the case" : in the case of the v11 or the v10 ?11g
    In my case : i'am on a v10.2.0.3 ::: Is there a bug ?Not that I know of.ok. So it is in V11 that you have an incorrect behaviour ....
    >>
    >
    Regards
    Jonathan LewisLAST NEWS : we have relaunched the query in SAS and observed that we have the same context of plan in both cases (by SAS en y TOAD) : ALL_ROWS.
    Very strange ...
    Last question :
    Just to be sure : When you talk about "First Rows plan" : it means that the retrieve data are restricted to the first rows encountered
    or
    it is just the plan of the query which is in "that context" which means that the engine works so although the whole data are retrieved ....
    thanks for your return

  • GROUP BY: determinstic function column of group by expression 10g vs 11g

    The following works in 10g but now fails in 11g.
    Simple description: If I create a view of a number and subtract 2 from that number
    and I group by the first column and include the 2nd column, it works in 10g and gives "not a group by column" in 11g.
    It seems that 10g knew the 2nd column was derived by the first column so grouping by the 1st column gave an automatic pass to the 2nd column.
    11g seems to be more strict (though I don't know why, if the 2nd column's function is purely deterministic as you would expect subtracting by 2 would be. Same is true for UPPER())
    Is there a reason for this change in behaviour in 11g?
    Is there some explicit reason for the change in functionality?
    Exact versions and results below
    Line: -----
    Connected to:
    Oracle Database 10g Release 10.2.0.3.0 - Production
    SQL> drop view v1;
    View dropped.
    SQL> drop view v2;
    View dropped.
    SQL>
    SQL> create view v1 as
    2 select '0' c1, 0 c2 from dual
    3 union all
    4 select '1', 1 from dual
    5 union all
    6 select '2', 2 from dual
    7 union all
    8 select '3', 3 from dual;
    View created.
    SQL>
    SQL>
    SQL> create view v2
    2 as select c1, upper(c1) c1u, c2, c2-2 c3
    3 from v1;
    View created.
    SQL>
    SQL> select c1, c1u
    2 from v2
    3 group by c1;
    C C
    1 1
    3 3
    0 0
    2 2
    SQL>
    SQL> select c1, c2, c3
    2 from v2
    3 group by c1, c2;
    C C2 C3
    1 1 -1
    3 3 1
    2 2 0
    0 0 -2
    -- =============================================================================================
    Connected to:
    Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    SQL> drop view v1;
    View dropped.
    SQL> drop view v2;
    View dropped.
    SQL>
    SQL> create view v1 as
    2 select '0' c1, 0 c2 from dual
    3 union all
    4 select '1', 1 from dual
    5 union all
    6 select '2', 2 from dual
    7 union all
    8 select '3', 3 from dual;
    View created.
    SQL>
    SQL>
    SQL> create view v2
    2 as select c1, upper(c1) c1u, c2, c2-2 c3
    3 from v1;
    View created.
    SQL>
    SQL> select c1, c1u
    2 from v2
    3 group by c1;
    select c1, c1u
    ERROR at line 1:
    ORA-00979: not a GROUP BY expression
    SQL>
    SQL> select c1, c2, c3
    2 from v2
    3 group by c1, c2;
    select c1, c2, c3
    ERROR at line 1:
    ORA-00979: not a GROUP BY expression
    Edited by: joriotis on Jul 25, 2011 11:01 AM
    Edited by: joriotis on Jul 25, 2011 11:03 AM

    Hi,
    Just 4 hours ago, someone else had a very similar question:
    Group by fails on ORA-00979
    Personally, I consider that a bug in Oracle 10. When you do a GROUP BY on a view, you can't expect the SQL engine to look at the view definition, and determine if one of the columns can be derived from another.
    In practice, it's easy enough to add c1u to the GROUP BY clause, or to use MAX (c1u) instead of c1u, to make your query work.

  • SECONDS_IN_WAIT column of v$session in 10gr2!!

    Hi, all.
    Recently, I have found the unbelievale value for SECONDS_IN_WAIT in v$session view. The database is 10.2.0.2.0.
    select sid, wait_time, seconds_in_waits,wait_class, event,state from v$session;
    SID WAIT_TIME SECONDS_IN_WAITS WAIT_CLASS EVENT
    500 0 117874 Cluster gc buffer busy WAITING
    In the above example, session 500 is waiting for something for 117874 seconds.
    117874 seconds is 32.7 hours(117874/60/60).
    Thus, session 500 is waiting for 32.7 hours.
    The unit of SECONDS_IN_WAITS column is really "seconds"????
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2088.htm#REFRN30223
    Thanks and Regards.

    Hi, yes the metric is on seconds, you must review the definition for this field on the view, look this.
    <br>
    <br>
    If WAIT_TIME = 0, then SECONDS_IN_WAIT is the seconds spent in the current wait condition.
    <br>
    <b>
    If WAIT_TIME > 0, then SECONDS_IN_WAIT is the seconds since the start of the last wait, and SECONDS_IN_WAIT - WAIT_TIME / 100 is the active seconds since the last wait ended.
    </b>
    <br>
    <br>
    <br>
    Regards.
    <br>

  • Incorrect data_length for columns with char semantics in 10g

    Hi,
    I was going through a few databases at my work place and I noticed something unusual.
    Database Server - Oracle 10g R2
    Database Client - Oracle 11g R1 (11.1.0.6.0 EE)
    Client OS - Win XP
    SQL>
    SQL> @ver
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    5 rows selected.
    SQL> --
    SQL> drop table t;
    Table dropped.
    SQL> create table t (
      2    a    char(3 char),
      3    b    char(3 byte),
      4    c    char(3),
      5    d    varchar2(3 char),
      6    e    varchar2(3 byte),
      7    f    varchar2(3)
      8  );
    Table created.
    SQL> --
    SQL> desc t
    Name                                      Null?    Type
    A                                                  CHAR(3 CHAR)
    B                                                  CHAR(3)
    C                                                  CHAR(3 CHAR)      <= why does it show "CHAR" ? isn't "BYTE" semantics the default i.e. CHAR(3) = CHAR(3 BYTE) ?
    D                                                  VARCHAR2(3 CHAR)
    E                                                  VARCHAR2(3)
    F                                                  VARCHAR2(3 CHAR)  <= same here; this should be VARCHAR2(3)
    SQL> --
    SQL> select table_name,
      2         column_name,
      3         data_type,
      4         data_length,
      5         data_precision,
      6         data_scale
      7    from user_tab_columns
      8   where table_name = 'T';
    TABLE_NAME   COLUMN_NAME  DATA_TYPE  DATA_LENGTH DATA_PRECISION DATA_SCALE
    T            A            CHAR                12                               <= why 12 and not 3 ? why multiply by 4 ?
    T            B            CHAR                 3
    T            C            CHAR                12                               <= same here
    T            D            VARCHAR2            12                               <= and here
    T            E            VARCHAR2             3
    T            F            VARCHAR2            12                               <= and here
    6 rows selected.
    SQL>
    SQL>I believe it multiplies the size by 4, because it shows 16 in user_tab_columns when the size is changed to 4.
    When I try this on 11g R1 server, it looks good -
    Database Server - Oracle 11g R1
    Database Client - Oracle 11g R1 (11.1.0.6.0 EE)
    Client OS - Win XP
    SQL>
    SQL> @ver
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    5 rows selected.
    SQL> --
    SQL> drop table t;
    Table dropped.
    SQL> create table t (
      2    a    char(3 char),
      3    b    char(3 byte),
      4    c    char(3),
      5    d    varchar2(3 char),
      6    e    varchar2(3 byte),
      7    f    varchar2(3)
      8  );
    Table created.
    SQL> --
    SQL> desc t
    Name                                      Null?    Type
    A                                                  CHAR(3 CHAR)
    B                                                  CHAR(3)
    C                                                  CHAR(3)
    D                                                  VARCHAR2(3 CHAR)
    E                                                  VARCHAR2(3)
    F                                                  VARCHAR2(3)
    SQL> --
    SQL> select table_name,
      2         column_name,
      3         data_type,
      4         data_length,
      5         data_precision,
      6         data_scale
      7    from user_tab_columns
      8   where table_name = 'T';
    TABLE_NAME   COLUMN_NAME  DATA_TYPE    DATA_LENGTH DATA_PRECISION DATA_SCALE
    T            A            CHAR                   3
    T            B            CHAR                   3
    T            C            CHAR                   3
    T            D            VARCHAR2               3
    T            E            VARCHAR2               3
    T            F            VARCHAR2               3
    6 rows selected.
    SQL>
    SQL>Is it a known bug ? Unfortunately, I do not have access to Metalink.
    Thanks,
    isotope
    Edited by: isotope on Mar 3, 2010 6:46 AM

    Anurag Tibrewal wrote:
    It is just because you have different NLS_LENGTH_SEMANTICS in v$nls_parameter for both the database. It is BYTE in R10 and CHAR in R11.
    I cannot query v$nls_parameter in the 10g database. I tried this testcase with the ALTER SESSION and checking with nls_session_parameter in both 10g and 11g. The client is 11g in each case.
    The DESCRIBE table looks ok, but the user_tab_column shows size*4.
    Testcase -
    cl scr
    select * from v$version;
    -- Try CHAR semantics
    alter session set nls_length_semantics=char;
    select * from nls_session_parameters where parameter = 'NLS_LENGTH_SEMANTICS';
    drop table t;
    create table t (
      a    char(3 char),
      b    char(3 byte),
      c    char(3),
      d    varchar2(3 char),
      e    varchar2(3 byte),
      f    varchar2(3)
    desc t
    select table_name,
           column_name,
           data_type,
           data_length,
           data_precision,
           data_scale
      from user_tab_columns
    where table_name = 'T';
    -- Try BYTE semantics
    alter session set nls_length_semantics=byte;
    select * from nls_session_parameters where parameter = 'NLS_LENGTH_SEMANTICS';
    drop table t;
    create table t (
      a    char(3 char),
      b    char(3 byte),
      c    char(3),
      d    varchar2(3 char),
      e    varchar2(3 byte),
      f    varchar2(3)
    desc t
    select table_name,
           column_name,
           data_type,
           data_length,
           data_precision,
           data_scale
      from user_tab_columns
    where table_name = 'T';In 10g R2 server -
    SQL>
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL>
    SQL> -- Try CHAR semantics
    SQL> alter session set nls_length_semantics=char;
    Session altered.
    SQL> select * from nls_session_parameters where parameter = 'NLS_LENGTH_SEMANTICS';
    PARAMETER            VALUE
    NLS_LENGTH_SEMANTICS CHAR
    SQL> --
    SQL> drop table t;
    Table dropped.
    SQL> create table t (
      2    a    char(3 char),
      3    b    char(3 byte),
      4    c    char(3),
      5    d    varchar2(3 char),
      6    e    varchar2(3 byte),
      7    f    varchar2(3)
      8  );
    Table created.
    SQL> --
    SQL> desc t
    Name                                            Null?    Type
    A                                                        CHAR(3)
    B                                                        CHAR(3 BYTE)
    C                                                        CHAR(3)
    D                                                        VARCHAR2(3)
    E                                                        VARCHAR2(3 BYTE)
    F                                                        VARCHAR2(3)
    SQL> --
    SQL> select table_name,
      2         column_name,
      3         data_type,
      4         data_length,
      5         data_precision,
      6         data_scale
      7    from user_tab_columns
      8   where table_name = 'T';
    TABLE_NAME        COLUMN_NAME  DATA_TYPE    DATA_LENGTH DATA_PRECISION DATA_SCALE
    T                 A            CHAR                  12      <==
    T                 B            CHAR                   3
    T                 C            CHAR                  12      <==
    T                 D            VARCHAR2              12      <==
    T                 E            VARCHAR2               3
    T                 F            VARCHAR2              12      <==
    6 rows selected.
    SQL>
    SQL> -- Try BYTE semantics
    SQL> alter session set nls_length_semantics=byte;
    Session altered.
    SQL> select * from nls_session_parameters where parameter = 'NLS_LENGTH_SEMANTICS';
    PARAMETER            VALUE
    NLS_LENGTH_SEMANTICS BYTE
    SQL> --
    SQL> drop table t;
    Table dropped.
    SQL> create table t (
      2    a    char(3 char),
      3    b    char(3 byte),
      4    c    char(3),
      5    d    varchar2(3 char),
      6    e    varchar2(3 byte),
      7    f    varchar2(3)
      8  );
    Table created.
    SQL> --
    SQL> desc t
    Name                                            Null?    Type
    A                                                        CHAR(3 CHAR)
    B                                                        CHAR(3)
    C                                                        CHAR(3)
    D                                                        VARCHAR2(3 CHAR)
    E                                                        VARCHAR2(3)
    F                                                        VARCHAR2(3)
    SQL> --
    SQL> select table_name,
      2         column_name,
      3         data_type,
      4         data_length,
      5         data_precision,
      6         data_scale
      7    from user_tab_columns
      8   where table_name = 'T';
    TABLE_NAME        COLUMN_NAME  DATA_TYPE    DATA_LENGTH DATA_PRECISION DATA_SCALE
    T                 A            CHAR                  12    <==
    T                 B            CHAR                   3
    T                 C            CHAR                   3
    T                 D            VARCHAR2              12   <==
    T                 E            VARCHAR2               3
    T                 F            VARCHAR2               3
    6 rows selected.
    SQL>
    SQL>In 11g R1 server -
    SQL>
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    5 rows selected.
    SQL>
    SQL> -- Try CHAR semantics
    SQL> alter session set nls_length_semantics=char;
    Session altered.
    SQL> select * from nls_session_parameters where parameter = 'NLS_LENGTH_SEMANTICS';
    PARAMETER                      VALUE
    NLS_LENGTH_SEMANTICS           CHAR
    1 row selected.
    SQL> --
    SQL> drop table t;
    Table dropped.
    SQL> create table t (
      2    a    char(3 char),
      3    b    char(3 byte),
      4    c    char(3),
      5    d    varchar2(3 char),
      6    e    varchar2(3 byte),
      7    f    varchar2(3)
      8  );
    Table created.
    SQL> --
    SQL> desc t
    Name                                      Null?    Type
    A                                                  CHAR(3)
    B                                                  CHAR(3 BYTE)
    C                                                  CHAR(3)
    D                                                  VARCHAR2(3)
    E                                                  VARCHAR2(3 BYTE)
    F                                                  VARCHAR2(3)
    SQL> --
    SQL> select table_name,
      2         column_name,
      3         data_type,
      4         data_length,
      5         data_precision,
      6         data_scale
      7    from user_tab_columns
      8   where table_name = 'T';
    TABLE_NAME   COLUMN_NAME  DATA_TYPE    DATA_LENGTH DATA_PRECISION DATA_SCALE
    T            A            CHAR                   3
    T            B            CHAR                   3
    T            C            CHAR                   3
    T            D            VARCHAR2               3
    T            E            VARCHAR2               3
    T            F            VARCHAR2               3
    6 rows selected.
    SQL>
    SQL> -- Try BYTE semantics
    SQL> alter session set nls_length_semantics=byte;
    Session altered.
    SQL> select * from nls_session_parameters where parameter = 'NLS_LENGTH_SEMANTICS';
    PARAMETER                      VALUE
    NLS_LENGTH_SEMANTICS           BYTE
    1 row selected.
    SQL> --
    SQL> drop table t;
    Table dropped.
    SQL> create table t (
      2    a    char(3 char),
      3    b    char(3 byte),
      4    c    char(3),
      5    d    varchar2(3 char),
      6    e    varchar2(3 byte),
      7    f    varchar2(3)
      8  );
    Table created.
    SQL> --
    SQL> desc t
    Name                                      Null?    Type
    A                                                  CHAR(3 CHAR)
    B                                                  CHAR(3)
    C                                                  CHAR(3)
    D                                                  VARCHAR2(3 CHAR)
    E                                                  VARCHAR2(3)
    F                                                  VARCHAR2(3)
    SQL> --
    SQL> select table_name,
      2         column_name,
      3         data_type,
      4         data_length,
      5         data_precision,
      6         data_scale
      7    from user_tab_columns
      8   where table_name = 'T';
    TABLE_NAME   COLUMN_NAME  DATA_TYPE    DATA_LENGTH DATA_PRECISION DATA_SCALE
    T            A            CHAR                   3
    T            B            CHAR                   3
    T            C            CHAR                   3
    T            D            VARCHAR2               3
    T            E            VARCHAR2               3
    T            F            VARCHAR2               3
    6 rows selected.
    SQL>
    SQL>isotope

  • Convert rows into columns nad vice versa in 10g

    how to convert rows into columns in 10g??

    Qwerty wrote:
    see below for rows to column case
    SQL> WITH t as
    2      (
    3       SELECT 'US' test_string FROM DUAL UNION
    4       SELECT 'AMERICA'  FROM DUAL UNION
    5       SELECT'HOLLYWOOD'  FROM DUAL UNION
    6       SELECT 'WASHINGTON'  FROM DUAL
    7      )
    8      select ltrim (sys_connect_by_path(test_string,','),',') test_string
    9        from (
    10     SELECT row_number() over(order by test_string) rno, test_string
    11       FROM t)
    12       WHERE connect_by_isleaf = 1 and rownum=1
    13       connect by rno = prior rno+1;
    TEST_STRING
    AMERICA,HOLLYWOOD,US,WASHINGTONI hope you can do it for column to rows now.That's not really rows to columns. That's rows to a column, which is more commonly called string aggregation.
    Rows to columns (or pivot) is more like:
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t as
      2       (
      3        SELECT 'US' test_string FROM DUAL UNION
      4        SELECT 'AMERICA'  FROM DUAL UNION
      5        SELECT'HOLLYWOOD'  FROM DUAL UNION
      6        SELECT 'WASHINGTON'  FROM DUAL
      7       )
      8  --
      9  select max(decode(rn,1,test_string)) as col_1
    10        ,max(decode(rn,2,test_string)) as col_2
    11        ,max(decode(rn,3,test_string)) as col_3
    12        ,max(decode(rn,4,test_string)) as col_4
    13* from (select test_string, row_number() over (order by test_string) as rn from t)
    SQL> /
    COL_1      COL_2      COL_3      COL_4
    AMERICA    HOLLYWOOD  US         WASHINGTON
    SQL>And columns to rows (or unpivot) is like:
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t as
      2       (
      3        SELECT 'US' col_1, 'AMERICA' col_2, 'HOLLYWOOD' col_3, 'WASHINGTON' col_4 FROM DUAL
      4       )
      5  --
      6  select col_1 as col from t union all
      7  select col_2 from t union all
      8  select col_3 from t union all
      9* select col_4 from t
    SQL> /
    COL
    US
    AMERICA
    HOLLYWOOD
    WASHINGTONor...
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t as
      2       (
      3        SELECT 'US' col_1, 'AMERICA' col_2, 'HOLLYWOOD' col_3, 'WASHINGTON' col_4 FROM DUAL
      4       )
      5  --
      6  select decode(rownum,1,col_1,2,col_2,3,col_3,4,col_4) as col
      7* from t, (select * from dual connect by rownum <= 4)
    SQL> /
    COL
    US
    AMERICA
    HOLLYWOOD
    WASHINGTON
    SQL>

  • How to enable AI(accent insensitiv) for one column without changing session

    Following is my test SQL:
    create table accent_test(col varchar2(10 char);
    insert into accent_test values('INDIA');
    insert into accent_test values('india');
    insert into accent_test values('InDiÄ ');
    Following SQL can only enable CI(Case insensitive), but can’t enable AI(accent insensitive):
    select *
    from accent_test
    where NLS_UPPER(col, 'NLS_SORT=GENERIC_BASELETTER') LIKE NLS_UPPER('INDIA', 'NLS_SORT=GENERIC_BASELETTER')
    COL
    INDIA
    india
    Upper SQL can’t return the third row ‘InDiÄ’ which includes accent character.
    I know following SQL can enable AI by changing the session. However it will change the whole session and other columns in one table:
    SQL> ALTER SESSION SET NLS_COMP=LINGUISTIC;
    SQL> ALTER SESSION SET NLS_SORT=GENERIC_BASELETTER;
    Is there any solution to enable AI for only one column without changing the session?

    convert(<Any Chinese Character>, 'US7ASCII') will all return same character '?'.might be an matter of using the right characterset:
    SQL> select 'ä' str, convert('ä', 'JA16SJIS') converted_str from dual union all
    select 'á', convert('á', 'JA16SJIS') from dual union all
    select 'â', convert('â', 'JA16SJIS') from dual union all
    select 'à',  convert('à', 'JA16SJIS') from dual
    STR CONVERTED_STR
    ä   a           
    á   a           
    â   a           
    à   a           
    4 rows selected.

  • Sort by columns once per session

    Hi there, I am using apex 3.1 and I have a report generated by a pl/sql function. There are several columns on which the user might sort. Is it possible to reset the sorting preferences when the user logs in? (like: a process running once per session?)
    thx in advance
    Edited by: 814932 on 23-Nov-2010 08:00

    You can use the <tt>apex_util.remove_sort_preferences</tt> method (although it is a bit of a blunt instrument). See the Admin guide for more information on user preferences.
    To run it once per session, code the call as an Application Process with execution point On New Session After Authentication.

  • Auto-increment  identity column through procedure in oracle 10g on windows

    Hi,
    I need identity primary key which should be auto increment before while inserting data into table.
    for this i had use sequence and then trigger to increment it.
    but now i need to increment it in Procedure, while my procedure is having code to insert data in same table which has primary key

    Hi,
    SNEHA RK wrote:
    Hi,
    I need identity primary key which should be auto increment before while inserting data into table.
    for this i had use sequence and then trigger to increment it.Right. Some database products have auto-increment columns, and they are really handy. Unfortunately, Oracle does not have auto-increment columns. A sequence is an auto-increment object, and it's the right way to automatically generate unique identifiers, but you need to explicity reference the sequence, either in you DML statements, or in a trigger that will automatically fire before a DML statement.
    but now i need to increment it in Procedure, while my procedure is having code to insert data in same table which has primary keyAre you saying that you need to increment the sequence, completely aside from INSERTing into the table?
    If so, just reference sequence_name.NEXTVAL wherever you want to. In PL/SQL, you can say
    SELECT  sequence_name.NEXTVAL
    INTO    number_variable
    FROM    dual;This works in any version of Oracle, but starting in Oracle 11, you also have the option of referencing te sequence without using dual, or any other table.
    I hope this answers your question.
    If not, post a complete script that people can run to re-create the problem and test their ideas.
    For example:
    -- Here are the table and the seqauence that I created:
    CREATE TABLE table_x ...
    CREATE SEQUENCE ...
    -- Here is the BEFORE INSERT trigger I wrote:
    CREATE OR REPLACE TRIGGER ...
    -- The trigger works exactly how I want it to in statements like this:
    INSERT INTO table_x ...
    -- So there are no problems (that I know of) with anything up to this point.
    -- Now I want to use the same sequence to ...
    -- so that when I execute a statement like this
    -- then the next time  I add a new row to the orginal table, like this
    INSERT INTO table_x ...
    -- then the contents of table_x should be ... because ...

  • Converting Columns to rows in Oracle 10g

    Hi
    i need hint to convert rows to columns.i had given the data strucure and expected output
    Source Table
    BU_ID     Prod_id     total_clients   Tot_men        Totwomen
    101        AAA           85              50          35
    101        BBB           40              20          20Expected Output
    BU_ID  Prod_id    Clint_info          Values
    101      AAA          total_clients      85
    101      AAA          Tot_men          50
    101      AAA          totwomen        35
    101      BBB           total_clients      40
    101      BBB           tot_men          20
    101      BBB           totwomen        20Thanks
    Edited by: Sami on Aug 1, 2012 8:25 PM

    Hi,
    Cross-join your table with a Counter Table , a table (or result set, as in the example below) that counts from 1 up to the number of columns you want to unpivot, like this:
    WITH     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 3     -- Number of columns to be unpivoted
    SELECT       s.bu_id
    ,       s.prod_id
    ,       CASE  c.n
              WHEN  1  THEN  'total_clients'
              WHEN  2  THEN  'total_men'
              WHEN  3  THEN  'total_women'
           END          AS client_info
    ,       CASE  c.n
              WHEN  1  THEN  total_clients
              WHEN  2  THEN  total_men
              WHEN  3  THEN  total_women
           END          AS values
    FROM            source_table  s
    CROSS JOIN     cntr           c
    ORDER BY  s.bu_id
    ,            s.prod_id
    ,       c.n
    ;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test this.
    The values column that you create can only have 1 data type. If the original, unpivoted columns have different data types, you may need to convert some of them in the CASE expression that defines values.

Maybe you are looking for