Query regarding Order of the column in a table

We have a table called EMP in several of our schemas. JOB is the third column in order. But in some schemas, JOB is not the third column. How can i find the schemas with EMP table where JOB column is not the third column?
SQL > desc emp
Name                                      Null?    Type
EMPNO                                     NOT NULL NUMBER(4)
ENAME                                              VARCHAR2(10)
JOB                                                VARCHAR2(9)
MGR                                                NUMBER(4)
HIREDATE                                           DATE
SAL                                                NUMBER(7,2)
COMM                                               NUMBER(7,2)
DEPTNO                                             NUMBER(2)
select column_name, column_id from dba_tab_Cols where
TABLE_NAME = 'EMP' AND OWNER = 'SCOTT' order by column_id;
COLUMN_NAME                     COLUMN_ID
EMPNO                                   1
ENAME                                   2
JOB                                     3       --------Third column
MGR                                     4
HIREDATE                                5
SAL                                     6
COMM                                    7
DEPTNO                                  8

Hi,
This should work:
select table_name, owner from dba_tab_cols
  where table_name = 'EMP'
  and column_name = 'JOB'
  and column_id != 3;//Johan

Similar Messages

  • Ho do I change the physical order of the columns in a table

    I want to change the physical order of the columns in a table, so that I get the expected order when I query like :
    select * from <tablename>

    Hi!
    There are different methods of doing that, you can either create a view on that table which will retrieve the columns in the correct order, or you can copy and rename the table using CREATE TABLE AS SELECT ..., or you can use the online table redefinition functionality if your using 10g.
    Regards,
    Petra

  • Query to get the data of all the columns in a table except any one column

    Can anyone please tell how to write a query to get the data of all the columns in a table except one particular column..
    For Example:
    Let us consider the EMP table.,
    From this table except the column comm all the remaining columns of the table should be listed
    For this we can write a query like this..
    Select empno, ename, job, mgr, sal, hiredate, deptno from emp;
    Just to avoid only one column, I mentioned all the remaining ( 7 ) columns of the table in the query..
    As the EMP table consists only 8 columns, it doesn't seem much difficult to mention all the columns in the query,
    but if a table have 100 columns in the table, then do we have to mention all the columns in the query..?
    Is there any other way of writing the query to get the required result..?
    Thanks..

    Your best best it to just list all the columns. Any other method will just cause more headaches and complicated code.
    If you really need to list all the columns for a table because you don't want to type them, just use something like...
    SQL> ed
    Wrote file afiedt.buf
      1  select trim(',' from sys_connect_by_path(column_name,',')) as columns
      2  from (select column_name, row_number() over (order by column_id) as column_id
      3        from user_tab_cols
      4        where column_name not in ('COMM')
      5        and   table_name = 'EMP'
      6       )
      7  where connect_by_isleaf = 1
      8  connect by column_id = prior column_id + 1
      9* start with column_id = 1
    SQL> /
    COLUMNS
    EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO
    SQL>

  • Problem with the order of the columns of a ALV

    I have a problem with a ALV, variants we keep this ALV does not record the order of the columns
    Thank you

    I suppose you want to change the sequence of columns of a ALV. If you can change it by clicking 'settings' of right-top corner of ALV. After done you can save the new settings into a new. If you find some abnormal behaviour, please check the settings by WDA component "wd_analyze_config_user".
    FYI.
    [http://help.sap.com/saphelp_nw70/helpdata/en/32/f26f73d81e11d1a26f0000e8a5a614/frameset.htm]

  • How to change the order of the columns in system matrix?

    Hi all,
    Is there any way to change the order of the columns in system matrix through SDK, without doing it from 'Form settings'??

    Hi ,
    is this true for the 'Active' property also , in CPRF table? I want to check whether the Item is active or not becuse, when I m trying to copy the value in item which is not active, I m given error. Is there any way to change or active the 'Active' flag in form settings at run-time?
    Any clue?
    Thanks in advance,......
    Binita

  • The order of the columns in GROUP BY doesn`t matter?  why?

    I did a little test and find out that the order of the columns in GROUP BY does not matter to ORACLE.
    Why? How does oracle do GROUP BY exactly?
    Could anyone show me its processing logic? maybe in pseudo-code?
    Thanks in advance.

    I mean,
    I thought oracle would group data based on the order of the columns in the GROUP BY LIST.
    For example: for select deptno, job, count(*) from emp group by deptno, job;
    I thought, oracle first would group the data based on deptno (10,20,30), e.g. in deptno=30, we got 6 employees.
    and then, group this 6 employees based on JOB (CLERK, SALESMAN, MANAGER).and
    for select job, deptno, count(*) from emp group by job, deptno;
    first would group the data based on JOB (CLERK, SALESMAN, MANAGER) e.g., for CLERK, we got 4 employees,
    and then, group this 4 employees based on deptno (10,20, 30).and to me, it seems that in some circumstances, their result could be different.
    So, I wonder if the order of the columns in GROUP BY Clause matter?

  • How to get the column name and table name with value

    Hi All
    I have one difficult requirement
    I have some column values and they have given some alias column names but i need to find the correct column name and table name from the database.
    For example value is "SRI" and i dont know the table and exact column name so is there any possibilities to find the column name and table name for the given value
    Thanks & Regards
    Srikkanth.M

    Searching all the database for a word...
    Courtesy of michaels...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    11g upwards
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from (select column_name,
                   table_name,
                   'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
              from cols
             where table_name in ('EMP', 'DEPT')),
           xmltable (str columns result varchar2(10) path '.')
    TABLE_NAME                     COLUMN_NAME                    SEARCH_STRING                    RESULT   
    DEPT                           DNAME                          es                               RESEARCH 
    EMP                            ENAME                          es                               JAMES    
    EMP                            JOB                            es                               SALESMAN 
    EMP                            JOB                            es                               SALESMAN 
    4 rows selected.

  • How to find the column name and table name with a value

    Hi All
    How to find the column name and table name with "Value".
    For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
    Any help is highly appricatable
    Thanks & Regards
    Srikkanth.M

    2 solutions by Michaels (the latter is 11g upwards only)...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from cols,
           xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
           columns result varchar2(10) path '.'
    where table_name in ('EMP', 'DEPT')
    TABLE_NAME           COLUMN_NAME          SEARCH_STRING        RESULT   
    DEPT                 DNAME                ES                   RESEARCH 
    DEPT                 DNAME                ES                   SALES    
    EMP                  ENAME                ES                   JONES    
    EMP                  ENAME                ES                   JAMES    
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   PRESIDENT
    EMP                  JOB                  ES                   SALESMAN 
    9 rows selected.

  • Query to know number of columns in a table

    please can anyone suggest me a query to know number of columns in a table i.e.
    if I want to know how many number of colums are present in a specific table then what would be the query
    Message was edited by:
    user625519

    Give this a shot:
    SELECT table_name,count(*) as "# of Columns"
    FROM dba_tab_cols
    WHERE table_name = <table name>
    GROUP BY table_name
    ORDER BY table_name;There are other views as well such as USER_TAB_COLS and ALL_TAB_COLS.
    HTH!

  • How I compare the columns of 2 tables

    Hi, what's the query I use to compare all the columns of 2 tables, or how I use the result of COLUMN_NAME in the DBA_TAB_COLS?
    Tnks for helping...
    Mnk

    I have this select:
    SELECT D.COLUMN_NAME AS CFINAL
    FROM DBA_TAB_COLS D,
    (SELECT A.COLUMN_NAME AS C1
    FROM DBA_TAB_COLS A
    WHERE (A.OWNER LIKE '%TEL_USJ07%' AND
    A.TABLE_NAME = 'BOLETOS')) F
    WHERE D.COLUMN_NAME = F.C1
    AND D.OWNER LIKE '%TEL_USJ07%'
    This will return the column's name where tabel_name LIKE BOLETOS.
    I want use this result in another select where the table have this columns and more, but I want to see all the results in the second table where the columns came from the first select.
    For example: the first select bring to me the columns: cod_tipo_bol and cod_tipo_corte, I want to see in the second select only the results of this 2 columns.
    THIS IS THE COLUMNS OF THE SECOND TABLE I WANT TO USE:
    cod_tipo_bol
    cod_frente_corte
    num_carga
    cod_caminhao
    cod_motorista
    lib_numero
    cod_enc_frente
    cod_div2
    cod_div3
    cod_div4
    bol_data
    cod_carregadora1
    cod_oper_carreg1
    cod_carregadora2
    cod_oper_carreg2
    cod_colhedora1
    cod_oper_colhed1
    cod_colhedora2
    cod_oper_colhed2
    cod_colhedora3
    cod_oper_colhed3
    cod_trat_reb
    cod_oper_trat_reb
    cod_trat_transb1
    cod_oper_transb1
    cod_trat_transb2
    cod_oper_transb2
    cod_trat_transb3
    cod_oper_transb3
    cod_julieta_sm_reboque
    bol_status
    --------

  • How to store data file name in one of the columns of staging table

    My requirement is to load data from .dat file to oracle staging table. I have done following steps:
    1. Created control file and stored in bin directory.
    2. Created data file and stored in bin directory.
    3. Registered a concurrent program with execution method as SQL*Loader.
    4. Added the concurrent program to request group.
    I am passing the file name as a parameter to concurrent program. When I am running the program, the data is getting loaded to the staging table correctly.
    Now I want to store the filename (which is passed as a parameter) in one of the columns of staging table. I tried different ways found through Google, but none of them worked. I am using the below control file:
    OPTIONS (SKIP = 1)
    LOAD DATA
    INFILE '&1'
    APPEND INTO TABLE XXCISCO_SO_INTF_STG_TB
    FIELDS TERMINATED BY ","
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    COUNTRY_NAME
    ,COUNTRY_CODE
    ,ORDER_CATEGORY
    ,ORDER_NUMBER
    ,RECORD_ID "XXCISCO_SO_INTF_STG_TB_S.NEXTVAL"
    ,FILE_NAME CONSTANT "&1"
    ,REQUEST_ID "fnd_global.conc_request_id"
    ,LAST_UPDATED_BY "FND_GLOBAL.USER_ID"
    ,LAST_UPDATE_DATE SYSDATE
    ,CREATED_BY "FND_GLOBAL.USER_ID"
    ,CREATION_DATE SYSDATE
    ,INTERFACE_STATUS CONSTANT "N"
    ,RECORD_STATUS CONSTANT "N"
    I want to store file name in the column FILE_NAME stated above. I tried with and without constant using "$1", "&1", ":$1", ":&1", &1, $1..... but none of them worked. Please suggest me the solution for this.
    Thanks,
    Abhay

    Pl post details of OS, database and EBS versions. There is no easy way to achieve this.
    Pl see previous threads on this topic
    SQL*Loader to insert data file name during load
    Sql Loader with new column
    HTH
    Srini

  • How we can replace the column in Core Table plz see this msg

    Hi,
    How we can replace the column in Core Table plz see this msg
    Req:
    when i push the Insert button the data inserted into the Table
    like
    Cols Values
    FOCD      CUFZ14
    PRDCD FU6
    Month 082008
    AgencyCD AG02
    PLAN 123
    This is FO_Plan Table....
    Requirement:
    i need at table show to replace the Prd_CD to Prd_Desc while inserting the above Row....
    There is no Prd_Desc in FO Plan Table....
    Prd_desc comes from Product Table.
    did u get my point...
    how to solve.
    Thanks
    Ram
    Edited by: Ram Vungarala on Sep 24, 2008 9:09 AM
    Edited by: Ram Vungarala on Sep 24, 2008 9:15 AM

    Hi,
    I'm not sure if I understood what are you trying to do. But you can modify your table in a backing bean code. JSF page code for a table:
    <af:table id="product_search_results_tbl" binding="#{backingBean.boundTable}" ... />
    And a backing bean code:
    import oracle.adf.view.faces.component.core.data.CoreTable;
    public class YourBackingBean {
        private CoreTable boundTable;
        public void setBoundTable(CoreTable boundTable) {
            this.boundTable = boundTable;
        public CoreTable getBoundTable() {
            return boundTable;
       public String insertButtonAction() {
          // Bind your button action to this method and modify here your bound table
         return null;
    {code}
    Look for column modification methods in a CoreTable class documentation.
    Marius                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to sum the column in a table seperated by sign.

    How to sum the column in a table separate by sign.
    For Example:
    A B
    10 MOHAN
    -15 KUMAR
    -25 MARCH
    50 MAY

    SELECT  SUM(CASE SIGN(A) WHEN 1 THEN A ELSE NULL END) SUM_POSTIIVE,
            SUM(CASE SIGN(A) WHEN -1 THEN A ELSE NULL END) SUM_NEGATIIVE
      FROM  tbl
    /SY.

  • Hiding the columns in data table in jsf

    Hi Guys,
    I have stuck one situation in my project . i.e i want to hide the columns in Data table in jsf.
    Please response this mail.
    Thanks
    Narne

    See this...
    [http://forum.java.sun.com/thread.jspa?threadID=5119514&messageID=9938606]

  • In Sales Order changing the column width to see all item desciption?

    When in the sales order screen .
    Expand the column width of say the item description.
    How do I save the column width for all the sales documents  for the field item description in sales order ?

    Hi,
    The column width of the Document will be defaulted to the same size at which the user has saved the last document.
    So, if a user has saved the Sales Order with a big column width for the 'Item Description' then after saving and re-entering into the Sales Order, the user can see the same column width for all the Sales Order's.
    I hope the above helps.
    Cheers~
    Jitin Chawla

Maybe you are looking for

  • Buongiorno Pests- How to get your money back and why you should

    Buogiorno, make millions from thousands of us who unknowingly are subscribed to services which we had no idea about. It is easy to get a refund and the service stopped because they are very aware that what they are doing is wrong, but they rely on th

  • Firefox will NOT Open...Crash report appears...WHY?

    AdapterDeviceID: 68a1 AdapterVendorID: 1002 Add-ons: [email protected]:0.79,{dc572301-7619-498c-a57d-39143191b318}:0.3.8.5,{BBDA0591-3099-440a-AA10-41764D9DB4DB}:2.0,{B7082FAA-CB62-4872-9106-E42DD88EDE45}:3.3.1,{972ce4c6-7e08-4474-a285-3208198ce6fd}:

  • Help Apache not working since 10.4.10 upgrade

    Hello I have web sharing turned on and I run a small web page on my mac to host photos and such. It was working great until I upgraded to 10.4.10. Now nothing will connect to my web server at all. I have a power PC mac. When I turn on web sharing on

  • Cant download allready purchased albums from itunes.

    ok so i cant listen or download albums or songs I've allready paid for. I mean I dont want to pay for them again bhecoss that would be a ripoff to charge twice for an album in three years

  • XSQLRequest : please help

    Hi Steve, I did load the XSQLConfig file into the database but now when i execute my stored procedure it gives the following error which is the improvement over the last error .now the error has changed to Oracle XSQL Programmatic Page Processor 0.9.