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
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,
ARThe 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 -
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,
NishaThank 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 -
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 deptIf you look in ORACLE_HOME/sqlplus/demo you'll find demobld.sql which contains the script the build all the scott tables.
-
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,
pKselect 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) -
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 raoThe script $ORACLE_HOME/sqlplus/demo/demobld.sql creates and
populates all the demonstration tables. You can extract the
actual INSERT statements from there. -
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. -
Basic Java Class with prints records out of the DEPT table
Can some one show a basic java class which will query the DEPT table, and print them out?
Nagarjuna,
the Oracle DBMS JDBC Developer's Guide is full of code examples.
http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/toc.htm
--olaf -
Retriving unique records and insert into cust and cust_det table
Hi,
uniq Table : EMP
column name
name
addr
city
addr1
city1
EMP table contains only unique records.
we neet to get the records from emp and insert into cust and cust_det accordingly
table : cust
empno : auto generated
name
addr
tabel : cust_det
empno : refer from cust
addr1
city1
plese help me to do this.user10069916 wrote:
can some one help me to resolve this plz. bit urgent..My boss says my work is more urgent than yours.
As I said, please read: {message:id=9360002} (especially point 2)
If you post sufficient information, then people can help you. the better the information you provide the faster people will be able to help... but still, if it's "urgent" then we can only assume you have a live production system that is failing, in which case you need to raise an SR with Oracle Support, as the forums are not the place for logging "urgent" production system issues. -
Sy-tabix in relation to LOOP AT and READ TABLE
Hi All,
As per SAP documentation,
1) While looping through an internal table (LOOP AT), sy-tabix contains the index number of current row(for standard and sorted tables)
2)When successfully reading from an internal table(READ TABLE), sy-tabix is set to the index of the result row.
But what happens when READ TABLE is used while looping through another internal table?
i.e. Loop at TAB1...
write sy-tabix.
READ TABLE TAB2...
write sy-tabix.
endloop.
If we are looping through 1st row of TAB1 and the result of read statement is found in 3rd row of TAB2, I expected that sy-tabix before READ would be 1 and after the READ be 3.
But, I found that sy-tabix remains unchanged at 1. Can someone expalin why?
Thanks,
JaganHi
If after reading the table TAB2 the system variable SY-TABIX has still the previous value, that menas the READ TABLE fails or it was read the first record of TAB2.
After READ TABLE TAB2 try to check the SY-SUBRC:
LOOP AT TAB1.
WRITE: / 'TAB1 index:', SY-TABIX.
READ TABLE TAB2 .........
IF SY-SUBRC = 0.
WRITE: 'TAB2 index:', SY-TABIX.
Try this:
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
FIELD1,
END OF ITAB2.
DATA: INDEX TYPE I.
DO 10 TIMES.
APPEND ITAB.
ENDDO.
DO 10 TIMES.
APPEND ITAB2.
ENDDO.
LOOP AT ITAB.
WRITE: / 'ITAB:', SY-TABIX.
INDEX = SY-TABIX + 2.
READ TABLE ITAB2 INDEX INDEX.
IF SY-SUBRC = 0.
WRITE: 'ITAB2:', SY-TABIX.
ENDIF.
ENDLOOP.
Max -
In Answers am seeing "Folder is Empty" for Logical Fact and Dimension Table
Hi All,
Am working on OBIEE Answers, on of sudden when i clicked on Logical Fact table it showed me as "folder is empty". I restarted all the services and then tried still showing same for Logical Fact and Dimension tables but am able to see all my reports in Shared Folders. I restarted the machine too but no change. Please help me out to resolve this issue.
Thanks in Advance.
Regards,
Rajkumar.First of all, follow the forum etiquette :
http://forums.oracle.com/forums/ann.jspa?annID=939
React or mark as anwser the post that the user gave.
And for your question, you must check the log for a possible corrupt catalog :
OracleBIData_Home\web\log\sawlog0.log -
Best practice when FACT and DIMENSION table are the same
Hi,
In my physical model I have some tables that are both fact and dimension table, i.e. in the BMM they are of course separated into Fact and Dim source (2 different units) and it works fine. But I can see that there will be trouble when having more fact tables and I e.g. have a Period dimension pointing to all the different fact tables (different sources).
Seems like the best solution to this is to have an alias of the fact/transaction table and have 2 "copies" of the transaction table (one for fact and one for dimension table) in the physical layer. Only bad thing is that there will then allways be 2 lookups in the same table when fetching data from the dimension and the fact table.
This is not built on a datawarehouse - so the architecture is thereby more complex. Hope this was understandable (trying to make a short story of it).
Any best practice on this? Or other suggestions.Id recommend creation of a view in the database. if its an oracle DB, materialised views would be a huge performance benefit. you just need to make sure that the MVs are updated when the source is updated.
-Domnic
Maybe you are looking for
-
"What's new" crashes the page when displaying a Team discussion item with a reply
Hi all, We have a SP2013 site with a "What's new" web part on its home page. Amongst other things, it is supposed to display stock-standard "Team discussion" updates. We have the following problems: 1. When a new "Team discussion" topic is created, w
-
I'm using a macbook pro and its fairly new and when i put my email address into app store i forgot a letter and now i cannot download updates, help?
-
Data Service - only returning 256 chars on text field
Using FlashBuilder Data Services - PHP service all working fine. Except the service is only returning the first 256 chars of a "text" field of my db table. The field has more than 256 chars and is marked up via the RTE component <TEXTFORMAT LEADING="
-
I just set up a user account for my daughter, and I went to 'browse' to her files in finder to find that I am not allowed to view them!!! I don't remember saying to protect these files. How do I change access permission. I eventually want to set up a
-
Runtime error when I start iTunes??
When I open my iTunes, I keep getting an error message of: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I can't figure it out or what to do. Can some