Emp and Dept Table Dropped

Hi ,
I have mistakenly altered and dropped the Employee and Department Table.
Can anybody help me with the Structure and Data of these tables ?
Or provide me with a procedure to re-create the Emp and Dept table ?
Thanks,
Nisha

Thank you very much !! That really helped.
You just have to execute that file.
For Eg in SQLPLUS : Just say ---> @D:\oracle\ora92\sqlplus\demo\demobld.sql

Similar Messages

  • How to get emp and dept tables of scott schema if they acdientally deleted

    Hii I accedentally modifiled emp and dept tables in scott schema.... Can you please tell how to recreate fresh emp and dept tables ? is there any way to get emp and dept tables? please help regarding this

    If you are on Oracle 10g version...
    The demo tableds under scott schema can be created using oracle supplied script.
    http://www.oracle.com/technology/sample_code/tech/sql_plus/htdocs/demobld.html
    Alternatively, this script exists in $ORACLE_HOME/sqlplus/demo directory.
    vr,
    Sudhakar B.

  • Emp and Dept table from JDeveloper tutorial

    Hi all,
    Under the tutorial for JDeveloper, I was going through the section 'Creating a Java Form Applet Using Wizard'. In one step, it asks to select 'Tables' - 'Emp' and 'Dept', but, the steps prior to that doesn't tell you how to add those tables in the database since I'm using my own database. Does anybody know where I can find the SQLScript to add these tables?
    Regards,
    AR

    The samples are based on the EMP and DEPT tables, which are typically owned by Scott (password tiger). Check first to see if this user exists in the database (it is created automatically when you do a default database creation). Otherwise, you can find the script in ORACLE_HOME\rdbms\admin\scott.sql.
    -- Brian

  • Data needed from emp and dept tables

    Wondering if somebody can querry the emp table and dept table that comes with some versions of oracle already built in.
    I need the data produced from these two querries
    select * from emp
    select * from dept

    If you look in ORACLE_HOME/sqlplus/demo you'll find demobld.sql which contains the script the build all the scott tables.

  • Emp and Dept tables

    Hi,
    I believe that when the database is installed, a few tables are created which all users have access to, i.e. emp and dept.
    Can anyone explain to me a bit more about where they are stored and particually where I can locate the scripts for these tables.
    Cheers,
    Nick

    run $ORACLE_HOME\sqlplus\demo\demobld.sql as the user in which you want to install these test tables. Historically, this has been in the SCOTT schema.
    HTH-Kevin

  • Matching EMP and DEPT

    Hi all,
    11.2.0.1
    I have departments in table DEPT which are  10 and 20. Department 10 has 100 employees in EMP while Department 20 has none in EMP, so it has no matching rows.
    How can I create a query such that all dept with no EMP will be displayed:
    DEPT      EMP
    ====      ====
    10         100
    20           0
    30          20
    Thanks,
    pK

    select d.deptno
    ,      (select count(*) from emp e where e.deptno = d.deptno) emps
    from   dept d;
    -- or:
    select *
    from ( select d.deptno
           ,      (select count(*) from emp e where e.deptno = d.deptno) emps
           from   dept d
    where emps = 0;

  • EMP and DEPT sampledata query (SOLVED)

    I don't have access to create tables at work - just to run selects on existing tables.
    I've used the SQL below to use the 2 standard Oracle test dept and emp tables for testing, but - is it possible to use SQL to join the tables, or can the GET table WITH table AS ... SQL only ever work on one table at a time, rather than allowing joins to be done?
    Thanks
    GET dept
    WITH dept AS
         (SELECT 10 deptno
               , 'ACCOUNTING ' dname
               , 'NEW YORK' loc
            FROM DUAL
          UNION ALL
          SELECT 20 deptno
               , 'RESEARCH   ' dname
               , 'DALLAS' loc
            FROM DUAL
          UNION ALL
          SELECT 30 deptno
               , 'SALES      ' dname
               , 'CHICAGO' loc
            FROM DUAL
          UNION ALL
          SELECT 40 deptno
               , 'OPERATIONS ' dname
               , 'BOSTON' loc
            FROM DUAL)
    SELECT *
      FROM dept;
    GET emp
    WITH emp AS
         (SELECT 7369 empno
               , 'SMITH' ename
               , 'CLERK' job
               , 7902 mgr
               , '17-Dec-80' hiredate
               , 800 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7499 empno
               , 'ALLEN' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '20-Feb-81' hiredate
               , 1600 sal
               , 300 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7521 empno
               , 'WARD' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '22-Feb-81' hiredate
               , 1250 sal
               , 500 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7566 empno
               , 'JONES' ename
               , 'MANAGER' job
               , 7839 mgr
               , '02-Apr-81' hiredate
               , 2975 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7654 empno
               , 'MARTIN' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '28-Sep-81' hiredate
               , 1250 sal
               , 1400 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7698 empno
               , 'BLAKE' ename
               , 'MANAGER' job
               , 7839 mgr
               , '01-May-81' hiredate
               , 2850 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7782 empno
               , 'CLARK' ename
               , 'MANAGER' job
               , 7839 mgr
               , '09-Jun-81' hiredate
               , 2450 sal
               , NULL comm
               , 10 deptno
            FROM DUAL
          UNION ALL
          SELECT 7788 empno
               , 'SCOTT' ename
               , 'ANALYST' job
               , 7566 mgr
               , '19-Apr-87' hiredate
               , 3000 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7839 empno
               , 'KING' ename
               , 'PRESIDENT' job
               , NULL mgr
               , '17-Nov-81' hiredate
               , 5000 sal
               , NULL comm
               , 10 deptno
            FROM DUAL
          UNION ALL
          SELECT 7844 empno
               , 'TURNER' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '08-Sep-81' hiredate
               , 1500 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7876 empno
               , 'ADAMS' ename
               , 'CLERK' job
               , 7788 mgr
               , '23-May-87' hiredate
               , 1100 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7900 empno
               , 'JAMES' ename
               , 'CLERK' job
               , 7698 mgr
               , '03-Dec-81' hiredate
               , 950 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7902 empno
               , 'FORD' ename
               , 'ANALYST' job
               , 7566 mgr
               , '03-Dec-81' hiredate
               , 3000 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7934 empno
               , 'MILLER' ename
               , 'CLERK' job
               , 7782 mgr
               , '23-Jan-82' hiredate
               , 1300 sal
               , NULL comm
               , 10 deptno
            FROM DUAL)
    SELECT *
      FROM emp;

    is it you requirement.
    WITH dept AS
         (SELECT 10 deptno
               , 'ACCOUNTING ' dname
               , 'NEW YORK' loc
            FROM DUAL
          UNION ALL
          SELECT 20 deptno
               , 'RESEARCH   ' dname
               , 'DALLAS' loc
            FROM DUAL
          UNION ALL
          SELECT 30 deptno
               , 'SALES      ' dname
               , 'CHICAGO' loc
            FROM DUAL
          UNION ALL
          SELECT 40 deptno
               , 'OPERATIONS ' dname
               , 'BOSTON' loc
            FROM DUAL),
    emp AS
         (SELECT 7369 empno
               , 'SMITH' ename
               , 'CLERK' job
               , 7902 mgr
               , '17-Dec-80' hiredate
               , 800 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7499 empno
               , 'ALLEN' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '20-Feb-81' hiredate
               , 1600 sal
               , 300 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7521 empno
               , 'WARD' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '22-Feb-81' hiredate
               , 1250 sal
               , 500 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7566 empno
               , 'JONES' ename
               , 'MANAGER' job
               , 7839 mgr
               , '02-Apr-81' hiredate
               , 2975 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7654 empno
               , 'MARTIN' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '28-Sep-81' hiredate
               , 1250 sal
               , 1400 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7698 empno
               , 'BLAKE' ename
               , 'MANAGER' job
               , 7839 mgr
               , '01-May-81' hiredate
               , 2850 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7782 empno
               , 'CLARK' ename
               , 'MANAGER' job
               , 7839 mgr
               , '09-Jun-81' hiredate
               , 2450 sal
               , NULL comm
               , 10 deptno
            FROM DUAL
          UNION ALL
          SELECT 7788 empno
               , 'SCOTT' ename
               , 'ANALYST' job
               , 7566 mgr
               , '19-Apr-87' hiredate
               , 3000 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7839 empno
               , 'KING' ename
               , 'PRESIDENT' job
               , NULL mgr
               , '17-Nov-81' hiredate
               , 5000 sal
               , NULL comm
               , 10 deptno
            FROM DUAL
          UNION ALL
          SELECT 7844 empno
               , 'TURNER' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '08-Sep-81' hiredate
               , 1500 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7876 empno
               , 'ADAMS' ename
               , 'CLERK' job
               , 7788 mgr
               , '23-May-87' hiredate
               , 1100 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7900 empno
               , 'JAMES' ename
               , 'CLERK' job
               , 7698 mgr
               , '03-Dec-81' hiredate
               , 950 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7902 empno
               , 'FORD' ename
               , 'ANALYST' job
               , 7566 mgr
               , '03-Dec-81' hiredate
               , 3000 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7934 empno
               , 'MILLER' ename
               , 'CLERK' job
               , 7782 mgr
               , '23-Jan-82' hiredate
               , 1300 sal
               , NULL comm
               , 10 deptno
            FROM DUAL)
    SELECT *
      FROM emp,dept
      where emp.deptno =dept.deptno

  • SQL Loader and multiple tables

    I know how to load multiple tables using the same set of data, but is it possible to load multiple tables using a different set of data for each table? Can someone point me to an example or tell me how to set up the ctl file.
    Thanks.

    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10825/ldr_control_file.htm#sthref852
    Distinguishing Different Input Record Formats
    A single datafile might contain records in a variety of formats. Consider the following data, in which emp and dept records are intermixed:
    1 50   Manufacturing       — DEPT record
    2 1119 Smith      50       — EMP record
    2 1120 Snyder     50
    1 60   Shipping
    2 1121 Stevens    60
    A record ID field distinguishes between the two formats. Department records have a 1 in the first column, while employee records have a 2. The following control file uses exact positioning to load this data:
    INTO TABLE dept
       WHEN recid = 1
       (recid  FILLER POSITION(1:1)  INTEGER EXTERNAL,
        deptno POSITION(3:4)  INTEGER EXTERNAL,
        dname  POSITION(8:21) CHAR)
    INTO TABLE emp
       WHEN recid <> 1
       (recid  FILLER POSITION(1:1)   INTEGER EXTERNAL,
        empno  POSITION(3:6)   INTEGER EXTERNAL,
        ename  POSITION(8:17)  CHAR,
        deptno POSITION(19:20) INTEGER EXTERNAL)

  • Tables drop down when center is selected

    I've been using the same main template in CS3 for a year. I just tried to test out a Google adsense search bar and had trouble with positioning it, so I attempted to put it inside of a table. for some reason when I add a table to any page on the site the table now drops down below the content in the side bars as soon as I select "center" to center the table. It doesn't matter the size of the table. It's the weirdest thing. Take this page for example.. http://isuckatgolf.net/Beercartcontestants.html
    If I were to add a table of any size below the Pink "GIRLS OF GOLF" , the table drops to even with the bottom of the two side column banner gifs.
    If I add a table of any size below the "go to girls of golf II" it renders fine and can be centered no problemo.
    I also just made a new page from template, added a table in the main content area, no problem. Then I added the standard size banner gif that is on many pages of the site to the left sidebar, like we always do, and the table dropped down to just below the level of the bottom of the 140x600 sidebar gif. Any suggestions?
    Thanks very much,

    Hope someone can help me out on this. I've been working on this issue and discoverd that the main content is dropping down in design view in Dreamweaver CS3, but is rendering fine in IE6, 7, and Firefox. I put one page live with an empty table. So it appears that the problem of the main content of my site is only dropping below the side column content in design view in Dreamweaver, not when I test it or put it live. Very strange. I can deal with it if I have to, but is there maybe a setting somewhere that I messed up or something?
    To recap if I insert a table into a page anywhere near the portion of the main content area, as soon as I hit "middle" to pull the table to the center it drops down below the 140x600 pixel side bar gifs leaving a huge blank space. This appears to only happen in Dreamweaver desgin view, not in a browser where the placement is fine. Is this weird or what?
    here is one page with a blank table inserted http://isuckatgolf.net/danielle.html
    Looks fine to me, but in Dreamweaver the table and all content below shows up below the level of the two sidebar 140x600 gifs.
    Hope someone can advise.
    Thanks everyone.
    Ken

  • How to get the default data in emp,dept tables

    Hi all
    i inserted some date into emp,dept tables.
    after that i want to default records what is containing at the
    time of instaling in oracle.
    what script can i run to get that data.
    Regards
    GB rao

    The script $ORACLE_HOME/sqlplus/demo/demobld.sql creates and
    populates all the demonstration tables. You can extract the
    actual INSERT statements from there.

  • Unable to descripe the table and unable to drop the table

    Hi,
    I have a temp table that we use like staging table to import the data in to the main table through some scheduled procedures.And that will dropped every day and will be created through the script.
    Some how while I am trying to drop the table manually got hanged, There after I could not find that table in dba_objects, dba_tables or any where.
    But Now I am unable to create that table manually(Keep on running the create command with out giving any error), Even I am not getting any error (keep on running )if I give drop/desc of table.
    Can you please any one help on this ? Is it some where got stored the table in DB or do we any option to repair the table ?
    SQL> select OWNER,OBJECT_NAME,OBJECT_TYPE,STATUS from dba_objects where OBJECT_NAME like 'TEMP%';
    no rows selected
    SQL> desc temp
    Thank in advance.

    Hi,
    if this table drops then it moved DBA_RECYCLEBIN table. and also original name of its changed automatically by oracle.
    For example :
    SQL> create table tst (col varchar2(10), row_chng_dt date);
    Table created.
    SQL> insert into tst values ('Version1', sysdate);
    1 row created.
    SQL> select * from tst ;
    COL        ROW_CHNG
    Version1   16:10:03
    If the RECYCLEBIN initialization parameter is set to ON (the default in 10g), then dropping this table will place it in the recyclebin:
    SQL> drop table tst;
    Table dropped.
    SQL> select object_name, original_name, type, can_undrop as "UND", can_purge as "PUR", droptime
      2  from recyclebin
    SQL> /
    OBJECT_NAME                    ORIGINAL_NAME TYPE  UND PUR DROPTIME
    BIN$HGnc55/7rRPgQPeM/qQoRw==$0 TST           TABLE YES YES 2013-10-08:16:10:12
    All that happened to the table when we dropped it was that it got renamed. The table data is still there and can be queried just like a normal table:
    SQL> alter session set nls_date_format='HH24:MI:SS' ;
    Session altered.
    SQL> select * from "BIN$HGnc55/7rRPgQPeM/qQoRw==$0" ;
    COL        ROW_CHNG
    Version1   16:10:03
    Since the table data is still there, it's very easy to "undrop" the table. This operation is known as a "flashback drop". The command is FLASHBACK TABLE... TO BEFORE DROP, and it simply renames the BIN$... table to its original name:
    SQL> flashback table tst to before drop;
    Flashback complete.
    SQL> select * from tst ;
    COL        ROW_CHNG
    Version1   16:10:03
    SQL> select * from recyclebin ;
    no rows selected
    It's important to know that after you've dropped a table, it has only been renamed; the table segments are still sitting there in your tablespace, unchanged, taking up space. This space still counts against your user tablespace quotas, as well as filling up the tablespace. It will not be reclaimed until you get the table out of the recyclebin. You can remove an object from the recyclebin by restoring it, or by purging it from the recyclebin.
    SQL> select object_name, original_name, type, can_undrop as "UND", can_purge as "PUR", droptime
      2  from recyclebin
    SQL> /
    OBJECT_NAME                    ORIGINAL_NAME TYPE                      UND PUR DROPTIME
    BIN$HGnc55/7rRPgQPeM/qQoRw==$0 TST           TABLE                     YES YES 2006-09-01:16:10:12
    SQL> purge table "BIN$HGnc55/7rRPgQPeM/qQoRw==$0" ;
    Table purged.
    SQL> select * from recyclebin ;
    no rows selected
    Thank you
    And check this link:
    http://www.orafaq.com/node/968
    http://docs.oracle.com/cd/B28359_01/server.111/b28310/tables011.htm
    Thank you

  • Drop and recreate table in stored procedure

    Hi all
    When creating tables using Transact-SQL scripts, I have always preferred to drop the table if it exists and then create it explicitly using CREATE TABLE.  For two reasons:
    1) It does not matter if it is the first time the SP is run ie. if I create the table manually in the first instance and just use TRUNCATE TABLE it could fail if the table is deleted
    2) I have control over the data types of the table fields
    Just recently though I discovered the error that can occur when dropping and creating a table in the same batch (see link below)
    Microsoft Website
    This causes me a problem when dropping and creating tables in stored procedures, as I understand that a stored procedure is in itself a single batch?
    Can I avoid this error in a stored procedure whilst continuing to drop and create tables?  Or should I be taking a different approach?
    Coding best practice advice would be greatly appreciated.
    Thank you

    Thanks Ronen
    Please see my second post immediately before your reply.
    Given that I need to store the data output in a physical table for use in QlikView, would you suggest truncating the table each time the SP runs?  And then having a script that handles both dropping and creating the physical table, and also creating
    the SP?
    >> QlikView
    QlikView is an Israeli company, right?
    In any case I am not familiar with QlikView's application, therefore I can only give you general information, based on assumptions regarding the application, and facts regarding the SQL Server.
    >> for use in QlikView
    I assume that external application use specific database structure (table
    structure) and it is change only in rare situations (for example CMS interface might change the tables if and when a module s update/install). In this case there is no need to drop the table and recreate it and TRUNCATE is the solution.
    >> would you suggest truncating the table each time the SP runs
    I am sorry but i cant recommend on TRUNCATE a table each time you execute SP, without know the exact reason for this logic. It sound to me, at this point of time (with the information that we have), that this
    is very bad logic (application architecture). As I wrote above, basing your application on TRUNCATING the table each time mean that you have problems with multi users. Thins about 2 people that try to execute the same SP at almost the same time. Think about
    locking in the SQL Server and bad data (one truncate while the other already inserted the new data and get no rows, if there is no locking).
    But TRUNCATE is much better in this case probably then DROP and DELETE, since it is faster, and locking will be shorter (hopefully the application use the correct locking). There are other reasons why TRUNCATE is better, and other people already mentioned
    most of them, but time in this scenario might be critical.
    >> having a script that handles both dropping and creating the physical table, and also creating the SP?
    I do not undestand what is this second step. we said that you truncate the table, so why do you need to
    dropping and creating the physical table and who
    creating the SP?
    Are you meaning that the application create the tables and SP?
    There are lot of application that during installation create the database structure. is this what you mean?
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Help with drop create and update table

    Sir/Madam,
    I have joined 5 tables and selected some columns ,then I need to update some columns in that. After updating I need to create a report with the new column values.
    To do this my method is to create temp table with the select statement then update the temp table , use this temp table for the report and then drop the temp table.
    Is there anyother way to do this ??
    Can I create a cursor and update the cursor column ??
    Does dynamic sql always be created as procedure ??

    Hi,
    you need to understand how eventing works in BSP and MVC architecture. Pls refer to the below link for a basic understanding of how BSP works - View, Controller and Model class concepts.
    http://www.sapdev.co.uk/webapps/bsp/washome.htm
    For your requirement -
    1. you need a view on which you will create a drop down list UI element and a table view element
    2. you will need to create a contoller class - this will be used to handle the event that will be triggered   when user selects an entry from drop down list
    3. you will need a model class in which you will write the business logic to retrieve employees of selected department.
    Pls search this forum or blogs for - data binding with BSPs, Table View. Pls read these concepts and try to develop your requirement. You can come back to this forum if you face any issues during development.
    hope this helps.

  • Way to programmatically drop-and-create-tables?

    Hi all,
    I have a persistence unit which exists to provide lookup information to my application. It is populated by data that is available at runtime. It takes a long time to parse this data, and therefore my intention is to only parse it once at the deployment target. To do this, I have created a main method that does all the parsing, and I do not set the toplink.ddl-generation property in persistence.xml. This causes the application to fail if the database is not created.
    However, this means that during the population stage, I must drop and create any existing tables. I had thought it would be possible to do this by obtaining an EntityManagerFactory which has a property map sent to it, containing the property toplink.ddl-generation set to drop-and-create-tables. But this does not work... the tables are not dropped (if they exist) and are not created (if the database is empty).
    Is it possible to do the drop-and-create-tables programmatically using the JPA?
    I may have another EntityManagerFactory open at the same time, which has been opened with the default options... would this be conflicting?

    I don't think there is any easy way to generate the default tables once your have created the EntityManagerFactory. You could use the EclipseLink/TopLink schemaframework or TableCreator to create tables using a EclipseLink/TopLink DatabaseSession.
    There is a DefaultTableGenerator in org.eclipse.persistence.tools.schemaframework, which may give you what you are looking for.
    -- James : http://www.eclipselink.org

  • Nested Loop and Driving Table.

    In the documentation I read these (/B19306_01/server.102/b14211/optimops.htm#i82080).
    The optimizer uses nested loop joins when joining small number of rows, with a good driving condition between the two tables. You drive from the outer loop to the inner loop, so the order of tables in the execution plan is important.
    The outer loop is the driving row source. It produces a set of rows for driving the join condition. The row source can be a table accessed using an index scan or a full table scan. Also, the rows can be produced from any other operation. For example, the output from a nested loop join can be used as a row source for another nested loop join.>
    I need some help to understand the bold line, i.e. so the order of tables in the execution plan is important.
    There are various conflicting opinion about the driving table (some says smaller and some says larger table is good option) and unfortunately I did not understand any of those logic.
    I read these threads/blogs also.
    CBO (optimizer) nest-loop join question
    http://hoopercharles.wordpress.com/2011/03/21/nested-loops-join-the-smaller-table-is-the-driving-table-the-larger-table-is-the-driving-table/
    In practice, I have seen explain plan for select e.ename,d.dname
      2  from emp e, dept d
      3  where e.deptno=d.deptno; usages emp as driving table (I only understood part of Aman's logic that dept table access would be faster when there would be an index available over it and hence it is in the inner loop)
    Whereas, SQL> explain plan for
      2  select e.ename,d.dname
      3  from emp e, dept d
      4  where e.deptno=d.deptno
      5  and e.deptno=20; usages dept as driving table.
    I have use USE_NL_WITH_INDEX with LEADING hint to change it, but it is giving some adverse effect (sometimes with optimizer_mode ALL_ROWS it is ignoring the hint completely).
    so the order of tables in the execution plan is important. How can I determine it ? I have read Tom's effective oracle by design but there is also no solution.

    Not sure I quite understand the question.
    Both threads contain lots of useful information about the broad considerations in play and debunking any myths.
    I need some help to understand the bold line, i.e.
    "so the order of tables in the execution plan is important"I read this as meaning just what it says, i.e. read the execution plan carefully and that
    NESTED LOOP
      A
      Bis not the same as
    NESTED LOOP
      B
      AA 10053 trace would normally be quite verbose about it's considerations as to join order.

Maybe you are looking for