ora4pm_feb20_24_25

drop table dept purge;

Table dropped.

SQL> ed
Wrote file afiedt.buf

1 create table dept
2 (sno number(2) constraint cu_sdno unique,
3 deptno number(2) constraint cu_sdno unique,
4 dname varchar2(15) constraint nn_dname not null,
5 loc varchar2(15) constraint nn_loc not null
6* )
SQL> /
deptno number(2) constraint cu_sdno unique,
*
ERROR at line 3:
ORA-02264: name already used by an existing constraint

SQL> ed
Wrote file afiedt.buf

1 create table dept
2 (sno number(2) ,
3 deptno number(2),
4 dname varchar2(15) constraint nn_dname not null,
5 loc varchar2(15) constraint nn_loc not null,
6 constraint cu_sdno unique(sno,deptno)
7* )
8 /

Table created.

SQL> ed
Wrote file afiedt.buf

1 create table dept
2 (sno number(2) ,
3 deptno number(2),
4 dname varchar2(15) constraint nn_dname not null,
5 loc varchar2(15) constraint nn_loc not null,
6 constraint cu_sdno unique(sno,deptno)
7* )
SQL>
SQL> clear screen
SQL> desc dept
Name Null? Type
—————————————– ——– —————————-
SNO NUMBER(2)
DEPTNO NUMBER(2)
DNAME NOT NULL VARCHAR2(15)
LOC NOT NULL VARCHAR2(15)

SQL> select constraint_name,index_name,constraint_type
2 from user_constraints
3 where table_name=
4
SQL> ed
Wrote file afiedt.buf

1 select constraint_name,index_name,constraint_type
2 from user_constraints
3* where table_name=’DEPT’
4 /

CONSTRAINT_NAME
——————————————————————————–
INDEX_NAME
——————————————————————————–
C

NN_DNAME

C

NN_LOC

C

CONSTRAINT_NAME
——————————————————————————–
INDEX_NAME
——————————————————————————–
C

CU_SDNO
CU_SDNO
U

SQL> set pagesize 100
SQL> /

CONSTRAINT_NAME
——————————————————————————–
INDEX_NAME
——————————————————————————–
C

CU_SDNO
CU_SDNO
U

NN_LOC

C

NN_DNAME

C

SQL> ed
Wrote file afiedt.buf

1 select constraint_name,index_name,constraint_type
2 from user_constraints
3* where table_name=’DEPT’
SQL>
SQL>
SQL> ed
Wrote file afiedt.buf

1 select constraint_name,index_name,constraint_type
2 from user_constraints
3* where table_name=’DEPT’
SQL>
SQL> insert into dept values(1,
2
SQL> ed
Wrote file afiedt.buf

1* insert into dept values(1,10,’ACC’,’NEW YORK’)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(1,20,’ACC’,’NEW YORK’)
2 /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(1,10,’ACC’,’NEW YORK’)
SQL> /
insert into dept values(1,10,’ACC’,’NEW YORK’)
*
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.CU_SDNO) violated

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(null,null,’ACC’,’NEW YORK’)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(null,null,’ACC’,’NEW YORK’)
SQL> /

1 row created.

SQL> clear screen
SQL> drop table dept purge;

Table dropped.

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 create table dept
2 (deptno number(2) constraint pk_dno primary key,
3 dname varchar2(15) constraint nn_dname not null,
4 loc varchar2(15) constraint nn_loc not null
5* )
SQL> /

Table created.

SQL> ed\

SQL> ed
Wrote file afiedt.buf

1 create table dept
2 (deptno number(2) constraint pk_dno primary key,
3 dname varchar2(15) constraint nn_dname not null,
4 loc varchar2(15) constraint nn_loc not null
5* )
6
SQL> ed
Wrote file afiedt.buf

1 select constraint_name,constraint_type,index_name
2 from user_constraints
3* where table_name=’DEPT’
SQL> /

CONSTRAINT_NAME
——————————————————————————–
C

INDEX_NAME
——————————————————————————–
NN_DNAME
C

NN_LOC
C

PK_DNO
P
PK_DNO

SQL> desc dept
Name Null? Type
—————————————– ——– —————————-
DEPTNO NOT NULL NUMBER(2)
DNAME NOT NULL VARCHAR2(15)
LOC NOT NULL VARCHAR2(15)

SQL>
SQL> insert
2
SQL> ed
Wrote file afiedt.buf

1* insert into dept values(10,’ACC’,’NEW YORK’)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(null,’ACC’,’NEW YORK’)
SQL> /
insert into dept values(null,’ACC’,’NEW YORK’)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into (“SCOTT”.”DEPT”.”DEPTNO”)

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(10,’ACC’,’NEW YORK’)
SQL> /
insert into dept values(10,’ACC’,’NEW YORK’)
*
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.PK_DNO) violated

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(‘null’,’ACC’,’NEW YORK’)
2 /
insert into dept values(‘null’,’ACC’,’NEW YORK’)
*
ERROR at line 1:
ORA-01722: invalid number

SQL> ed
Wrote file afiedt.buf

1* insert into dept(dname,loc) values(‘ACC’,’NEW YORK’)
2 /
insert into dept(dname,loc) values(‘ACC’,’NEW YORK’)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into (“SCOTT”.”DEPT”.”DEPTNO”)

SQL> clear screen
SQL> drop table dept purge;

Table dropped.

SQL> ed
Wrote file afiedt.buf

1 create table dept
2 (sno number(2),
3 deptno number(2),
4 dname varchar2(15) constraint nn_dname not null,
5 loc varchar2(15) constraint nn_loc not null,
6 constraint cpk_sdno primary key(sno,deptno)
7* )
SQL> /

Table created.

SQL> ed
Wrote file afiedt.buf

1 create table dept
2 (sno number(2),
3 deptno number(2),
4 dname varchar2(15) constraint nn_dname not null,
5 loc varchar2(15) constraint nn_loc not null,
6 constraint cpk_sdno primary key(sno,deptno)
7* )
SQL>
SQL> desc dept
Name Null? Type
—————————————– ——– —————————-
SNO NOT NULL NUMBER(2)
DEPTNO NOT NULL NUMBER(2)
DNAME NOT NULL VARCHAR2(15)
LOC NOT NULL VARCHAR2(15)

SQL> clear screen
SQL> insert into dept values(1,10,’ACC’,’NY’);

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(1,20,’ACC’,’NY’)
2 /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(null,null,’ACC’,’NY’)
SQL> /
insert into dept values(null,null,’ACC’,’NY’)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into (“SCOTT”.”DEPT”.”SNO”)

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(null,10,’ACC’,’NY’)
SQL> /
insert into dept values(null,10,’ACC’,’NY’)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into (“SCOTT”.”DEPT”.”SNO”)

SQL> clear screen
SQL> drop table dept purge;

Table dropped.

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1* drop table emp purge
SQL> /
drop table emp purge
*
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by foreign keys

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1* drop table emp purge
SQL>
SQL> /
drop table emp purge
*
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by foreign keys

SQL> ed
Wrote file afiedt.buf

1* drop table emp cascade purge
SQL> /
drop table emp cascade purge
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed
Wrote file afiedt.buf

1* drop table emp cascade constraint purge
SQL> /

Table dropped.

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 CREATE TABLE Dept
2 (
3 Deptno Number(2) Constraint Deptno_PK PRIMARY KEY,
4 Dname Varchar2(20) Constraint Dname_NN NOT NULL,
5 Loc Varchar2(20) Constraint Loc_NN NOT NULL
6* )
SQL> /

Table created.

SQL> INSERT INTO DEPT VALUES (10, ‘ACCOUNTING’, ‘NEW YORK’);

1 row created.

SQL> INSERT INTO DEPT VALUES (20, ‘RESEARCH’, ‘DALLAS’);

1 row created.

SQL> INSERT INTO DEPT VALUES (30, ‘SALES’, ‘CHICAGO’);

1 row created.

SQL> INSERT INTO DEPT VALUES (40, ‘OPERATIONS’, ‘BOSTON’);

1 row created.

SQL> commit;

Commit complete.

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 CREATE TABLE Emp
2 (Empno Number(4) Constraint Empno_PK PRIMARY KEY,
3 Ename Varchar2(20) Constraint Ename_NN NOT NULL,
4 Job Varchar2(15) Constraint Job_NN NOT NULL,
5 Mgr Number(4) Constraint Mgr_FK_Self REFERENCES
6 Emp(Empno) ON DELETE SET NULL,
7 Hiredate Date Constraint Hiredate_NN NOT NULL,
8 Sal Number(8,2) Constraint Sal_NN NOT NULL,
9 Comm Number(8,2),
10 Deptno Number Constraint Deptno_FK REFERENCES Dept(Deptno)
11 ON DELETE CASCADE
12* )
13 /

Table created.

SQL> desc emp
Name Null? Type
—————————————– ——– —————————-
EMPNO NOT NULL NUMBER(4)
ENAME NOT NULL VARCHAR2(20)
JOB NOT NULL VARCHAR2(15)
MGR NUMBER(4)
HIREDATE NOT NULL DATE
SAL NOT NULL NUMBER(8,2)
COMM NUMBER(8,2)
DEPTNO NUMBER

SQL> insert into emp values(7369,’SMITH’,’CLERK’,7902,’17-dec-80′,800,null,20)
2
SQL>
SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7369,’SMITH’,’CLERK’,7902,’17-dec-80′,800,null,20)
SQL> /
insert into emp values(7369,’SMITH’,’CLERK’,7902,’17-dec-80′,800,null,20)
*
ERROR at line 1:
ORA-02291: integrity constraint (SCOTT.MGR_FK_SELF) violated – parent key not
found

SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7369,’SMITH’,’CLERK’,null,’17-dec-80′,800,null,20)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7839,’KING’,’PRE’,null,’17-JAN-81′,5000,null,10)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7566,’JONES’,’MANA’,7839,’17-JAN-81′,2975,null,20)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7902,’FORD’,’ANA’,7566,’03-dec-81′,3000,null,20)
SQL> /

1 row created.

SQL> commit;

Commit complete.

SQL> clear screen
SQL> select *from dept;

DEPTNO DNAME LOC
———- ——————– ——————–
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> select *from emp;

EMPNO ENAME JOB MGR HIREDATE SAL
———- ——————– ————— ———- ——— ———-
COMM DEPTNO
———- ———-
7369 SMITH CLERK 17-DEC-80 800
20

7839 KING PRE 17-JAN-81 5000
10

7566 JONES MANA 7839 17-JAN-81 2975
20

7902 FORD ANA 7566 03-DEC-81 3000
20

SQL> set line 120
SQL> /

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
———- ——————– ————— ———- ——— ———- ———- ———-
7369 SMITH CLERK 17-DEC-80 800 20
7839 KING PRE 17-JAN-81 5000 10
7566 JONES MANA 7839 17-JAN-81 2975 20
7902 FORD ANA 7566 03-DEC-81 3000 20

SQL> clear screen
SQL> /

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
———- ——————– ————— ———- ——— ———- ———- ———-
7369 SMITH CLERK 17-DEC-80 800 20
7839 KING PRE 17-JAN-81 5000 10
7566 JONES MANA 7839 17-JAN-81 2975 20
7902 FORD ANA 7566 03-DEC-81 3000 20

SQL> select *from dept;

DEPTNO DNAME LOC
———- ——————– ——————–
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> update emp set mgr=7902
2 where empno=7369;

1 row updated.

SQL> commit;

Commit complete.

SQL> clear screen
SQL> select *from dept;

DEPTNO DNAME LOC
———- ——————– ——————–
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> select *from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
———- ——————– ————— ———- ——— ———- ———- ———-
7369 SMITH CLERK 7902 17-DEC-80 800 20
7839 KING PRE 17-JAN-81 5000 10
7566 JONES MANA 7839 17-JAN-81 2975 20
7902 FORD ANA 7566 03-DEC-81 3000 20

SQL> delete from dept
2 where deptno=10;

1 row deleted.

SQL> select *from dept;

DEPTNO DNAME LOC
———- ——————– ——————–
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> select *from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
———- ——————– ————— ———- ——— ———- ———- ———-
7369 SMITH CLERK 7902 17-DEC-80 800 20
7566 JONES MANA 17-JAN-81 2975 20
7902 FORD ANA 7566 03-DEC-81 3000 20

SQL> delete from ep
2
SQL>
SQL> ed
Wrote file afiedt.buf

1 delete from emp
2* where empno=7566
SQL>
SQL> /

1 row deleted.

SQL> select *from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
———- ——————– ————— ———- ——— ———- ———- ———-
7369 SMITH CLERK 7902 17-DEC-80 800 20
7902 FORD ANA 03-DEC-81 3000 20

SQL>
SQL>
SQL>
SQL>
SQL> clear screen
SQL> exit

—-feb 24—
drop table emp purge;

Table dropped.

SQL> clear screen
SQL> create
2
SQL> ed
Wrote file afiedt.buf

1 create table emp
2 (deptno number(2) constraint chk_dno check(deptno=(select deptno from dept))
3* )
4 /
(deptno number(2) constraint chk_dno check(deptno=(select deptno from dept))
*
ERROR at line 2:
ORA-02251: subquery not allowed here

SQL> ed
Wrote file afiedt.buf

1 create table emp
2 (deptno number(2) constraint chk_dno check(deptno=(select deptno from dept))
3* )
SQL>
SQL> create sequence s1;
create sequence s1
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> drop sequence s1;

Sequence dropped.

SQL> create sequence s1;

Sequence created.

SQL> select s1.nextval from dual
2 ;

NEXTVAL
———-
1

SQL> /

NEXTVAL
———-
2

SQL> /

NEXTVAL
———-
3

SQL> create table emp
2 (deptno number(2) constraint chk_dno check(deptno=(select deptno from dept))
3 )
4
SQL> ed
Wrote file afiedt.buf

1 create table emp
2 (
3 deptno number(2) constraint chk_dno check(deptno=s1.nextval)
4* )
5 /
)
*
ERROR at line 4:
ORA-02438: Column check constraint cannot reference other columns

SQL> ed
Wrote file afiedt.buf

1 create table emp
2 (
3 deptno number(2) constraint chk_dno check(deptno=s1.currval)
4* )
SQL> /
)
*
ERROR at line 4:
ORA-02438: Column check constraint cannot reference other columns

SQL> clear screen
SQL> drop table dept purge;

Table dropped.

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 CREATE TABLE Dept
2 (
3 Deptno number(2) constraint dno_pk PRIMARY KEY
4 constraint Deptno_Chk CHECK(Deptno BETWEEN 10 and 99),
5 Dname varchar2(15) constraint dname_nn NOT NULL constraint Dname_Chk CHECK(Dname=UPPER(Dname)),
6 Loc varchar2(15) default ‘NEW YORK’
7 constraint Loc_Chk CHECK
8 (Loc IN(‘NEW YORK’,’DALLAS’,’BOSTON’,’CHICAGO’))
9* );
10 /
);
*
ERROR at line 9:
ORA-00922: missing or invalid option

SQL> ed
Wrote file afiedt.buf

1 CREATE TABLE Dept
2 (
3 Deptno number(2) constraint dno_pk PRIMARY KEY
4 constraint Deptno_Chk CHECK(Deptno BETWEEN 10 and 99),
5 Dname varchar2(15) constraint dname_nn NOT NULL constraint Dname_Chk CHECK(Dname=UPPER(Dname)),
6 Loc varchar2(15) default ‘NEW YORK’
7 constraint Loc_Chk CHECK
8 (Loc IN(‘NEW YORK’,’DALLAS’,’BOSTON’,’CHICAGO’))
9* )
SQL> /

Table created.

SQL> desc dept
Name Null? Type
—————————————– ——– —————————-
DEPTNO NOT NULL NUMBER(2)
DNAME NOT NULL VARCHAR2(15)
LOC VARCHAR2(15)

SQL> insert into dept values(
2
SQL> ed
Wrote file afiedt.buf

1* insert into dept values(5,’acc’,’newyork’)
2 /
insert into dept values(5,’acc’,’newyork’)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.LOC_CHK) violated

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(5,’acc’,’NEW YORK’)
SQL> /
insert into dept values(5,’acc’,’NEW YORK’)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.DNAME_CHK) violated

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(5,’ACC’,’NEW YORK’)
SQL> /
insert into dept values(5,’ACC’,’NEW YORK’)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.DEPTNO_CHK) violated

SQL> ed
Wrote file afiedt.buf

1* insert into dept values(10,’ACC’,’NEW YORK’)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into dept(dname,loc) values(‘RES’,’DALLAS’)
SQL> /
insert into dept(dname,loc) values(‘RES’,’DALLAS’)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into (“SCOTT”.”DEPT”.”DEPTNO”)

SQL> ed
Wrote file afiedt.buf

1* insert into dept(deptno,dname) values(20,’RES’)
SQL> /

1 row created.

SQL> select *from dept;

DEPTNO DNAME LOC
———- ————— —————
10 ACC NEW YORK
20 RES NEW YORK

SQL> insert into dept(deptno,dname) values(20,’RES’)
2
SQL> ed
Wrote file afiedt.buf

1* insert into dept(deptno,dname) values(20,’RES’)
2 \
3
SQL> select *from dept;

DEPTNO DNAME LOC
———- ————— —————
10 ACC NEW YORK
20 RES NEW YORK

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 CREATE TABLE Emp
2 (
3 Empno Number(4) Constraint Empno_Pk PRIMARY KEY,
4 Ename Varchar2(20) Constraint ename_NN NOT NULL
5 CHECK((SUBSTR(Ename,1,1) BETWEEN ‘A’ AND ‘Z’) AND Ename=UPPER(Ename)),
6 Job Varchar2(15) Constraint Job_Chk
7 CHECK(Job IN(‘ANALYST’,’CLERK’,’MANAGER’,’PRESIDENT’,
8 ‘SALESMAN’)),
9 Hiredate date DEFAULT SYSDATE,
10 Sal Number(8,2) Constraint Sal_NN NOT NULL
11 Constraint CHK_Sal CHECK(Sal BETWEEN 1000 and 10000),
12 Comm number(8,2),
13 Deptno Number(2),
14 Constraint Tot_Sal_Chk CHECK(Sal+Comm<=100000) 15* ) SQL> /

Table created.

SQL> desc emp
Name Null? Type
—————————————– ——– —————————-
EMPNO NOT NULL NUMBER(4)
ENAME NOT NULL VARCHAR2(20)
JOB VARCHAR2(15)
HIREDATE DATE
SAL NOT NULL NUMBER(8,2)
COMM NUMBER(8,2)
DEPTNO NUMBER(2)

SQL> insert into emp values(7369,’
2
SQL>
SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7369,’1smith’,’clerk’,’12-jan-20′,800,99999,20)
SQL> /
insert into emp values(7369,’1smith’,’clerk’,’12-jan-20′,800,99999,20)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.TOT_SAL_CHK) violated

SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7369,’1smith’,’clerk’,’12-jan-20′,800,100,20)
SQL> /
insert into emp values(7369,’1smith’,’clerk’,’12-jan-20′,800,100,20)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.CHK_SAL) violated

SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7369,’1smith’,’clerk’,’12-jan-20′,1000,100,20)
SQL> /
insert into emp values(7369,’1smith’,’clerk’,’12-jan-20′,1000,100,20)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.JOB_CHK) violated

SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7369,’1smith’,’CLERK’,’12-jan-20′,1000,100,20)
SQL> /
insert into emp values(7369,’1smith’,’CLERK’,’12-jan-20′,1000,100,20)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.SYS_C0010476) violated

SQL> select column_name,constraint_name
2 from user_cons_columns
3 where table_name=’EMP’;

COLUMN_NAME
——————————————————————————–
CONSTRAINT_NAME
——————————————————————————–
ENAME
ENAME_NN

SAL
SAL_NN

ENAME
SYS_C0010476

COLUMN_NAME
——————————————————————————–
CONSTRAINT_NAME
——————————————————————————–
JOB
JOB_CHK

SAL
CHK_SAL

SAL
TOT_SAL_CHK

COLUMN_NAME
——————————————————————————–
CONSTRAINT_NAME
——————————————————————————–
COMM
TOT_SAL_CHK

EMPNO
EMPNO_PK

8 rows selected.

SQL> set pagesize 100
SQL> /

COLUMN_NAME
——————————————————————————–
CONSTRAINT_NAME
——————————————————————————–
EMPNO
EMPNO_PK

COMM
TOT_SAL_CHK

SAL
TOT_SAL_CHK

SAL
CHK_SAL

JOB
JOB_CHK

ENAME
SYS_C0010476

SAL
SAL_NN

ENAME
ENAME_NN

8 rows selected.

SQL> ed
Wrote file afiedt.buf

1 select column_name,constraint_name
2 from user_cons_columns
3* where table_name=’EMP’
SQL> insert into emp values(7369,’1smith’,’CLERK’,’12-jan-20′,1000,100,20)
2
SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7369,’SMITH’,’CLERK’,’12-jan-20′,1000,100,20)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into emp values(7369,’SMITH’,’CLERK’,’12-jan-20′,1000,100,20)
SQL>
SQL>
SQL> clear screen
SQL> drop table dept;

Table dropped.

SQL> ed
Wrote file afiedt.buf

1* drop table emp purge
SQL> /

Table dropped.

SQL> clear screen
SQL> CREATE TABLE EMP
2 (EMPNO NUMBER(4),
3 ENAME VARCHAR2(10),
4 JOB VARCHAR2(9),
5 MGR NUMBER(4),
6 HIREDATE DATE,
7 SAL NUMBER(7, 2),
8 COMM NUMBER(7, 2),
9 DEPTNO NUMBER(2));

Table created.

SQL>
SQL> INSERT INTO EMP VALUES
2 (7369, ‘SMITH’, ‘CLERK’, 7902,
3 TO_DATE(’17-DEC-1980′, ‘DD-MON-YYYY’), 800, NULL, 20);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7499, ‘ALLEN’, ‘SALESMAN’, 7698,
3 TO_DATE(’20-FEB-1981′, ‘DD-MON-YYYY’), 1600, 300, 30);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7521, ‘WARD’, ‘SALESMAN’, 7698,
3 TO_DATE(’22-FEB-1981′, ‘DD-MON-YYYY’), 1250, 500, 30);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7566, ‘JONES’, ‘MANAGER’, 7839,
3 TO_DATE(‘2-APR-1981’, ‘DD-MON-YYYY’), 2975, NULL, 20);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7654, ‘MARTIN’, ‘SALESMAN’, 7698,
3 TO_DATE(’28-SEP-1981′, ‘DD-MON-YYYY’), 1250, 1400, 30);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7698, ‘BLAKE’, ‘MANAGER’, 7839,
3 TO_DATE(‘1-MAY-1981’, ‘DD-MON-YYYY’), 2850, NULL, 30);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7782, ‘CLARK’, ‘MANAGER’, 7839,
3 TO_DATE(‘9-JUN-1981’, ‘DD-MON-YYYY’), 2450, NULL, 10);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7788, ‘SCOTT’, ‘ANALYST’, 7566,
3 TO_DATE(’09-DEC-1982′, ‘DD-MON-YYYY’), 3000, NULL, 20);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7839, ‘KING’, ‘PRESIDENT’, NULL,
3 TO_DATE(’17-NOV-1981′, ‘DD-MON-YYYY’), 5000, NULL, 10);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7844, ‘TURNER’, ‘SALESMAN’, 7698,
3 TO_DATE(‘8-SEP-1981’, ‘DD-MON-YYYY’), 1500, 0, 30);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7876, ‘ADAMS’, ‘CLERK’, 7788,
3 TO_DATE(’12-JAN-1983′, ‘DD-MON-YYYY’), 1100, NULL, 20);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7900, ‘JAMES’, ‘CLERK’, 7698,
3 TO_DATE(‘3-DEC-1981’, ‘DD-MON-YYYY’), 950, NULL, 30);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7902, ‘FORD’, ‘ANALYST’, 7566,
3 TO_DATE(‘3-DEC-1981’, ‘DD-MON-YYYY’), 3000, NULL, 20);

1 row created.

SQL> INSERT INTO EMP VALUES
2 (7934, ‘MILLER’, ‘CLERK’, 7782,
3 TO_DATE(’23-JAN-1982′, ‘DD-MON-YYYY’), 1300, NULL, 10);

1 row created.

SQL>
SQL> CREATE TABLE DEPT
2 (DEPTNO NUMBER(2),
3 DNAME VARCHAR2(14),
4 LOC VARCHAR2(13) );

Table created.

SQL>
SQL> INSERT INTO DEPT VALUES (10, ‘ACCOUNTING’, ‘NEW YORK’);

1 row created.

SQL> INSERT INTO DEPT VALUES (20, ‘RESEARCH’, ‘DALLAS’);

1 row created.

SQL> INSERT INTO DEPT VALUES (30, ‘SALES’, ‘CHICAGO’);

1 row created.

SQL> INSERT INTO DEPT VALUES (40, ‘OPERATIONS’, ‘BOSTON’);

1 row created.

SQL> clear screen
SQL> commit;

Commit complete.

SQL> clear screen
SQL> update emp set mgr=7902
2 wher
3
SQL> ed
Wrote file afiedt.buf

1 update emp set mgr=7902,deptno=50
2* where empno=7369
SQL> /

1 row updated.

SQL> insert into dept values(10,
2
SQL>
SQL> update emp set mgr=7902,deptno=50
2 where empno=7369
3
SQL> ed
Wrote file afiedt.buf

1 update emp set mgr=7902,deptno=50,job=null
2* where empno=7369
SQL> /

1 row updated.

SQL> insert into dept values(10,’SW’,’HYD’);

1 row created.

SQL> clear screen
SQL> alter table dept add constraint
2
SQL> ed
Wrote file afiedt.buf

1* alter table dept add constraint pk_dno primary key(deptno)
2 /
alter table dept add constraint pk_dno primary key(deptno)
*
ERROR at line 1:
ORA-02437: cannot validate (SCOTT.PK_DNO) – primary key violated

SQL> select deptno
2 from
3
SQL> ed
Wrote file afiedt.buf

1 select deptno
2 from dept
3* where deptno is null
4 /

no rows selected

SQL> ed
Wrote file afiedt.buf

1 select deptno,count(*)
2 from dept
3 group by deptno
4* having count(*)>1
SQL> /

DEPTNO COUNT(*)
———- ———-
10 2

SQL> select *from dept
2 where deptno=10;

DEPTNO DNAME LOC
———- ————– ————-
10 ACCOUNTING NEW YORK
10 SW HYD

SQL> delete from dept
2 where dname=’SW’;

1 row deleted.

SQL> alter table dept add constraint pk_dno primary key(deptno)
2 /

Table altered.

SQL> ed
Wrote file afiedt.buf

1 ALTER TABLE Emp ADD Constraint Emp_Mgr_FK FOREIGN KEY(Mgr)
2* REFERENCES Emp(empno)
SQL> /
REFERENCES Emp(empno)
*
ERROR at line 2:
ORA-02270: no matching unique or primary key for this column-list

SQL> ed
Wrote file afiedt.buf

1 ALTER TABLE Emp ADD Constraint Emp_Mgr_FK FOREIGN KEY(Mgr)
2* REFERENCES Emp(empno)
3
SQL> alter
2
SQL> ed
Wrote file afiedt.buf

1* alter table emp add constraint pk_dno primary key(empno)
2 /
alter table emp add constraint pk_dno primary key(empno)
*
ERROR at line 1:
ORA-02264: name already used by an existing constraint

SQL> ed
Wrote file afiedt.buf

1* alter table emp add constraint pk_empno primary key(empno)
SQL> /

Table altered.

SQL> ALTER TABLE Emp ADD Constraint Emp_Mgr_FK FOREIGN KEY(Mgr)
2 REFERENCES Emp(empno)
3 /

Table altered.

SQL> select *from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7369 SMITH 7902 17-DEC-80 800
50

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 09-DEC-82 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 12-JAN-83 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> set line 100
SQL> /

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
———- ———- ——— ———- ——— ———- ———- ———-
7369 SMITH 7902 17-DEC-80 800 50
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10

14 rows selected.

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1* alter table emp modify job constraint nn_job not null
SQL> /
alter table emp modify job constraint nn_job not null
*
ERROR at line 1:
ORA-02296: cannot enable (SCOTT.NN_JOB) – null values found

SQL> select empno,job
2 from emp
3 where job is null;

EMPNO JOB
———- ———
7369

SQL> update emp set job=’CLERK’
2 where empno=7369;;
where empno=7369;
*
ERROR at line 2:
ORA-00933: SQL command not properly ended

SQL> e
SP2-0042: unknown command “e” – rest of line ignored.
SQL> ed
Wrote file afiedt.buf

1 update emp set job=’CLERK’
2* where empno=7369
SQL> /

1 row updated.

SQL> alter table emp modify job constraint nn_job not null
2 /

Table altered.

SQL>
———–feb 25—-
select *from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7369 SMITH CLERK 7902 17-DEC-80 800
50

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 09-DEC-82 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 12-JAN-83 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> set line 100
SQL> set pagesize 100
SQL> clear screen
SQL> /

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
———- ———- ——— ———- ——— ———- ———- ———-
7369 SMITH CLERK 7902 17-DEC-80 800 50
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10

14 rows selected.

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 ALTER TABLE Emp ADD CONSTRAINT Dept_Dno_FK FOREIGN KEY(Deptno)
2* REFERENCES Dept MODIFY(Deptno NOT NULL)
SQL> /
ALTER TABLE Emp ADD CONSTRAINT Dept_Dno_FK FOREIGN KEY(Deptno)
*
ERROR at line 1:
ORA-02298: cannot validate (SCOTT.DEPT_DNO_FK) – parent keys not found

SQL> select deptno
2
SQL>
SQL> ed
Wrote file afiedt.buf

1 select deptno
2 from emp
3* where deptno not in(select deptno from dept)
SQL> /

DEPTNO
———-
50

SQL> ed
Wrote file afiedt.buf

1 select deptno
2 from emp
3* where deptno not in(select deptno from dept)
4 /

DEPTNO
———-
50

SQL> update emp set deptno=20\
2
SQL>
SQL> ed
Wrote file afiedt.buf

1 update emp set deptno=20
2* where deptno=50
SQL> /

1 row updated.

SQL> ALTER TABLE Emp ADD CONSTRAINT Dept_Dno_FK FOREIGN KEY(Deptno)
2 REFERENCES Dept MODIFY(Deptno NOT NULL)
3 /

Table altered.

SQL> ed
Wrote file afiedt.buf

1 ALTER TABLE Emp ADD CONSTRAINT Dept_Dno_FK FOREIGN KEY(Deptno)
2* REFERENCES Dept MODIFY(Deptno NOT NULL)
SQL>
SQL> clear screen
SQL> select constraint_name,index_name,constraint_type
2 from user_constraints
3 where table_name=’DEPT’;

CONSTRAINT_NAME
—————————————————————————————————-
INDEX_NAME
—————————————————————————————————-
C

PK_DNO
PK_DNO
P

SQL> ed
Wrote file afiedt.buf

1 select constraint_name,index_name,constraint_type
2 from user_constraints
3* where table_name=’EMP’
SQL> /

CONSTRAINT_NAME
—————————————————————————————————-
INDEX_NAME
—————————————————————————————————-
C

DEPT_DNO_FK

R

SYS_C0010493

C

NN_JOB

C

EMP_MGR_FK

R

PK_EMPNO
PK_EMPNO
P

SQL> alter table
2
SQL> ed
Wrote file afiedt.buf

1* alter table dept drop primary key
2 /
alter table dept drop primary key
*
ERROR at line 1:
ORA-02273: this unique/primary key is referenced by some foreign keys

SQL> ed
Wrote file afiedt.buf

1* alter table dept drop primary key cascade
SQL> /

Table altered.

SQL> select constraint_name,index_name,constraint_type
2 from user_constraints
3 where table_name=’DEPT’;

no rows selected

SQL> select constraint_name,index_name,constraint_type
2 from user_constraints
3 where table_name=’EMP’
4 /

CONSTRAINT_NAME
—————————————————————————————————-
INDEX_NAME
—————————————————————————————————-
C

PK_EMPNO
PK_EMPNO
P

EMP_MGR_FK

R

SYS_C0010493

C

NN_JOB

C

SQL> alter table dept add constraint pk_dno primary key(deptno);

Table altered.

SQL> ed
Wrote file afiedt.buf

1* alter table dept add constraint pk_dno primary key(deptno)
2
SQL> ed
Wrote file afiedt.buf

1 ALTER TABLE Emp ADD CONSTRAINT Dept_Dno_FK FOREIGN KEY(Deptno)
2* REFERENCES Dept(Deptno)
SQL> /

Table altered.

SQL> select constraint_name,index_name,constraint_type
2 from user_constraints
3 where table_name=’DEPT’
4
SQL> ed
Wrote file afiedt.buf

1 select constraint_name,index_name,constraint_type.status
2 from user_constraints
3* where table_name=’DEPT’
SQL> /
select constraint_name,index_name,constraint_type.status
*
ERROR at line 1:
ORA-00904: “CONSTRAINT_TYPE”.”STATUS”: invalid identifier

SQL> ed
Wrote file afiedt.buf

1 select constraint_name,index_name,constraint_type,status
2 from user_constraints
3* where table_name=’DEPT’
SQL> /

CONSTRAINT_NAME
—————————————————————————————————-
INDEX_NAME
—————————————————————————————————-
C STATUS
– ——–
PK_DNO
PK_DNO
P ENABLED

SQL> ed
Wrote file afiedt.buf

1 select constraint_name,index_name,constraint_type,status
2 from user_constraints
3* where table_name=’EMP’
SQL> /

CONSTRAINT_NAME
—————————————————————————————————-
INDEX_NAME
—————————————————————————————————-
C STATUS
– ——–
DEPT_DNO_FK

R ENABLED

SYS_C0010493

C ENABLED

NN_JOB

C ENABLED

EMP_MGR_FK

R ENABLED

PK_EMPNO
PK_EMPNO
P ENABLED

SQL> ed
Wrote file afiedt.buf

1* alter table dept disable primary key
SQL> /
alter table dept disable primary key
*
ERROR at line 1:
ORA-02297: cannot disable constraint (SCOTT.PK_DNO) – dependencies exist

SQL> ed
Wrote file afiedt.buf

1* alter table dept disable primary key cascade
SQL> /

Table altered.

SQL> select constraint_name,index_name,constraint_type,status
2 from user_constraints
3 where table_name=’DEPT’;

CONSTRAINT_NAME
—————————————————————————————————-
INDEX_NAME
—————————————————————————————————-
C STATUS
– ——–
PK_DNO

P DISABLED

SQL> ed
Wrote file afiedt.buf

1 select constraint_name,index_name,constraint_type,status
2 from user_constraints
3* where table_name=’EMP’
SQL> /

CONSTRAINT_NAME
—————————————————————————————————-
INDEX_NAME
—————————————————————————————————-
C STATUS
– ——–
DEPT_DNO_FK

R DISABLED

SYS_C0010493

C ENABLED

NN_JOB

C ENABLED

EMP_MGR_FK

R ENABLED

PK_EMPNO
PK_EMPNO
P ENABLED

SQL> drop table dept purge
2
SQL> ed
Wrote file afiedt.buf

1* drop table dept purge
2 /
drop table dept purge
*
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by foreign keys

SQL> ed
Wrote file afiedt.buf

1* drop table dept cascade constraint purge
SQL> /

Table dropped.

SQL> ed
Wrote file afiedt.buf

1* drop table dept cascade constraint purge
SQL>
SQL> select constraint_name,index_name,constraint_type,status
2 from user_constraints
3 where table_name=’EMP’
4 /

CONSTRAINT_NAME
—————————————————————————————————-
INDEX_NAME
—————————————————————————————————-
C STATUS
– ——–
PK_EMPNO
PK_EMPNO
P ENABLED

EMP_MGR_FK

R ENABLED

SYS_C0010493

C ENABLED

NN_JOB

C ENABLED

SQL> clear screen
SQL> select *from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
———- ———- ——— ———- ——— ———- ———- ———-
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10

14 rows selected.

SQL> select *from dept;
select *from dept
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> CREATE TABLE DEPT
2 (DEPTNO NUMBER(2),
3 DNAME VARCHAR2(14),
4 LOC VARCHAR2(13) );

Table created.

SQL>
SQL> INSERT INTO DEPT VALUES (10, ‘ACCOUNTING’, ‘NEW YORK’);

1 row created.

SQL> INSERT INTO DEPT VALUES (20, ‘RESEARCH’, ‘DALLAS’);

1 row created.

SQL> INSERT INTO DEPT VALUES (30, ‘SALES’, ‘CHICAGO’);

1 row created.

SQL> INSERT INTO DEPT VALUES (40, ‘OPERATIONS’, ‘BOSTON’);

1 row created.

SQL>
SQL> commit;

Commit complete.

SQL> clear screen
SQL> select *from salgrade;

GRADE LOSAL HISAL
———- ———- ———-
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999

SQL> clear screen
SQL> /

GRADE LOSAL HISAL
———- ———- ———-
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999

SQL> ed
Wrote file afiedt.buf

1 select empno,ename,sal,emp.deptno,dname
2* from emp,dept
SQL> /

EMPNO ENAME SAL DEPTNO DNAME
———- ———- ———- ———- ————–
7369 SMITH 800 20 ACCOUNTING
7499 ALLEN 1600 30 ACCOUNTING
7521 WARD 1250 30 ACCOUNTING
7566 JONES 2975 20 ACCOUNTING
7654 MARTIN 1250 30 ACCOUNTING
7698 BLAKE 2850 30 ACCOUNTING
7782 CLARK 2450 10 ACCOUNTING
7788 SCOTT 3000 20 ACCOUNTING
7839 KING 5000 10 ACCOUNTING
7844 TURNER 1500 30 ACCOUNTING
7876 ADAMS 1100 20 ACCOUNTING
7900 JAMES 950 30 ACCOUNTING
7902 FORD 3000 20 ACCOUNTING
7934 MILLER 1300 10 ACCOUNTING
7369 SMITH 800 20 RESEARCH
7499 ALLEN 1600 30 RESEARCH
7521 WARD 1250 30 RESEARCH
7566 JONES 2975 20 RESEARCH
7654 MARTIN 1250 30 RESEARCH
7698 BLAKE 2850 30 RESEARCH
7782 CLARK 2450 10 RESEARCH
7788 SCOTT 3000 20 RESEARCH
7839 KING 5000 10 RESEARCH
7844 TURNER 1500 30 RESEARCH
7876 ADAMS 1100 20 RESEARCH
7900 JAMES 950 30 RESEARCH
7902 FORD 3000 20 RESEARCH
7934 MILLER 1300 10 RESEARCH
7369 SMITH 800 20 SALES
7499 ALLEN 1600 30 SALES
7521 WARD 1250 30 SALES
7566 JONES 2975 20 SALES
7654 MARTIN 1250 30 SALES
7698 BLAKE 2850 30 SALES
7782 CLARK 2450 10 SALES
7788 SCOTT 3000 20 SALES
7839 KING 5000 10 SALES
7844 TURNER 1500 30 SALES
7876 ADAMS 1100 20 SALES
7900 JAMES 950 30 SALES
7902 FORD 3000 20 SALES
7934 MILLER 1300 10 SALES
7369 SMITH 800 20 OPERATIONS
7499 ALLEN 1600 30 OPERATIONS
7521 WARD 1250 30 OPERATIONS
7566 JONES 2975 20 OPERATIONS
7654 MARTIN 1250 30 OPERATIONS
7698 BLAKE 2850 30 OPERATIONS
7782 CLARK 2450 10 OPERATIONS
7788 SCOTT 3000 20 OPERATIONS
7839 KING 5000 10 OPERATIONS
7844 TURNER 1500 30 OPERATIONS
7876 ADAMS 1100 20 OPERATIONS
7900 JAMES 950 30 OPERATIONS
7902 FORD 3000 20 OPERATIONS
7934 MILLER 1300 10 OPERATIONS

56 rows selected.

SQL> clear screen
SQL> /

EMPNO ENAME SAL DEPTNO DNAME
———- ———- ———- ———- ————–
7369 SMITH 800 20 ACCOUNTING
7499 ALLEN 1600 30 ACCOUNTING
7521 WARD 1250 30 ACCOUNTING
7566 JONES 2975 20 ACCOUNTING
7654 MARTIN 1250 30 ACCOUNTING
7698 BLAKE 2850 30 ACCOUNTING
7782 CLARK 2450 10 ACCOUNTING
7788 SCOTT 3000 20 ACCOUNTING
7839 KING 5000 10 ACCOUNTING
7844 TURNER 1500 30 ACCOUNTING
7876 ADAMS 1100 20 ACCOUNTING
7900 JAMES 950 30 ACCOUNTING
7902 FORD 3000 20 ACCOUNTING
7934 MILLER 1300 10 ACCOUNTING
7369 SMITH 800 20 RESEARCH
7499 ALLEN 1600 30 RESEARCH
7521 WARD 1250 30 RESEARCH
7566 JONES 2975 20 RESEARCH
7654 MARTIN 1250 30 RESEARCH
7698 BLAKE 2850 30 RESEARCH
7782 CLARK 2450 10 RESEARCH
7788 SCOTT 3000 20 RESEARCH
7839 KING 5000 10 RESEARCH
7844 TURNER 1500 30 RESEARCH
7876 ADAMS 1100 20 RESEARCH
7900 JAMES 950 30 RESEARCH
7902 FORD 3000 20 RESEARCH
7934 MILLER 1300 10 RESEARCH
7369 SMITH 800 20 SALES
7499 ALLEN 1600 30 SALES
7521 WARD 1250 30 SALES
7566 JONES 2975 20 SALES
7654 MARTIN 1250 30 SALES
7698 BLAKE 2850 30 SALES
7782 CLARK 2450 10 SALES
7788 SCOTT 3000 20 SALES
7839 KING 5000 10 SALES
7844 TURNER 1500 30 SALES
7876 ADAMS 1100 20 SALES
7900 JAMES 950 30 SALES
7902 FORD 3000 20 SALES
7934 MILLER 1300 10 SALES
7369 SMITH 800 20 OPERATIONS
7499 ALLEN 1600 30 OPERATIONS
7521 WARD 1250 30 OPERATIONS
7566 JONES 2975 20 OPERATIONS
7654 MARTIN 1250 30 OPERATIONS
7698 BLAKE 2850 30 OPERATIONS
7782 CLARK 2450 10 OPERATIONS
7788 SCOTT 3000 20 OPERATIONS
7839 KING 5000 10 OPERATIONS
7844 TURNER 1500 30 OPERATIONS
7876 ADAMS 1100 20 OPERATIONS
7900 JAMES 950 30 OPERATIONS
7902 FORD 3000 20 OPERATIONS
7934 MILLER 1300 10 OPERATIONS

56 rows selected.

SQL> ed
Wrote file afiedt.buf

1 select empno,ename,sal,grade,emp.deptno,dname
2* from emp,dept,salgrade
3 /

EMPNO ENAME SAL GRADE DEPTNO DNAME
———- ———- ———- ———- ———- ————–
7369 SMITH 800 1 20 ACCOUNTING
7499 ALLEN 1600 1 30 ACCOUNTING
7521 WARD 1250 1 30 ACCOUNTING
7566 JONES 2975 1 20 ACCOUNTING
7654 MARTIN 1250 1 30 ACCOUNTING
7698 BLAKE 2850 1 30 ACCOUNTING
7782 CLARK 2450 1 10 ACCOUNTING
7788 SCOTT 3000 1 20 ACCOUNTING
7839 KING 5000 1 10 ACCOUNTING
7844 TURNER 1500 1 30 ACCOUNTING
7876 ADAMS 1100 1 20 ACCOUNTING
7900 JAMES 950 1 30 ACCOUNTING
7902 FORD 3000 1 20 ACCOUNTING
7934 MILLER 1300 1 10 ACCOUNTING
7369 SMITH 800 2 20 ACCOUNTING
7499 ALLEN 1600 2 30 ACCOUNTING
7521 WARD 1250 2 30 ACCOUNTING
7566 JONES 2975 2 20 ACCOUNTING
7654 MARTIN 1250 2 30 ACCOUNTING
7698 BLAKE 2850 2 30 ACCOUNTING
7782 CLARK 2450 2 10 ACCOUNTING
7788 SCOTT 3000 2 20 ACCOUNTING
7839 KING 5000 2 10 ACCOUNTING
7844 TURNER 1500 2 30 ACCOUNTING
7876 ADAMS 1100 2 20 ACCOUNTING
7900 JAMES 950 2 30 ACCOUNTING
7902 FORD 3000 2 20 ACCOUNTING
7934 MILLER 1300 2 10 ACCOUNTING
7369 SMITH 800 3 20 ACCOUNTING
7499 ALLEN 1600 3 30 ACCOUNTING
7521 WARD 1250 3 30 ACCOUNTING
7566 JONES 2975 3 20 ACCOUNTING
7654 MARTIN 1250 3 30 ACCOUNTING
7698 BLAKE 2850 3 30 ACCOUNTING
7782 CLARK 2450 3 10 ACCOUNTING
7788 SCOTT 3000 3 20 ACCOUNTING
7839 KING 5000 3 10 ACCOUNTING
7844 TURNER 1500 3 30 ACCOUNTING
7876 ADAMS 1100 3 20 ACCOUNTING
7900 JAMES 950 3 30 ACCOUNTING
7902 FORD 3000 3 20 ACCOUNTING
7934 MILLER 1300 3 10 ACCOUNTING
7369 SMITH 800 4 20 ACCOUNTING
7499 ALLEN 1600 4 30 ACCOUNTING
7521 WARD 1250 4 30 ACCOUNTING
7566 JONES 2975 4 20 ACCOUNTING
7654 MARTIN 1250 4 30 ACCOUNTING
7698 BLAKE 2850 4 30 ACCOUNTING
7782 CLARK 2450 4 10 ACCOUNTING
7788 SCOTT 3000 4 20 ACCOUNTING
7839 KING 5000 4 10 ACCOUNTING
7844 TURNER 1500 4 30 ACCOUNTING
7876 ADAMS 1100 4 20 ACCOUNTING
7900 JAMES 950 4 30 ACCOUNTING
7902 FORD 3000 4 20 ACCOUNTING
7934 MILLER 1300 4 10 ACCOUNTING
7369 SMITH 800 5 20 ACCOUNTING
7499 ALLEN 1600 5 30 ACCOUNTING
7521 WARD 1250 5 30 ACCOUNTING
7566 JONES 2975 5 20 ACCOUNTING
7654 MARTIN 1250 5 30 ACCOUNTING
7698 BLAKE 2850 5 30 ACCOUNTING
7782 CLARK 2450 5 10 ACCOUNTING
7788 SCOTT 3000 5 20 ACCOUNTING
7839 KING 5000 5 10 ACCOUNTING
7844 TURNER 1500 5 30 ACCOUNTING
7876 ADAMS 1100 5 20 ACCOUNTING
7900 JAMES 950 5 30 ACCOUNTING
7902 FORD 3000 5 20 ACCOUNTING
7934 MILLER 1300 5 10 ACCOUNTING
7369 SMITH 800 1 20 RESEARCH
7499 ALLEN 1600 1 30 RESEARCH
7521 WARD 1250 1 30 RESEARCH
7566 JONES 2975 1 20 RESEARCH
7654 MARTIN 1250 1 30 RESEARCH
7698 BLAKE 2850 1 30 RESEARCH
7782 CLARK 2450 1 10 RESEARCH
7788 SCOTT 3000 1 20 RESEARCH
7839 KING 5000 1 10 RESEARCH
7844 TURNER 1500 1 30 RESEARCH
7876 ADAMS 1100 1 20 RESEARCH
7900 JAMES 950 1 30 RESEARCH
7902 FORD 3000 1 20 RESEARCH
7934 MILLER 1300 1 10 RESEARCH
7369 SMITH 800 2 20 RESEARCH
7499 ALLEN 1600 2 30 RESEARCH
7521 WARD 1250 2 30 RESEARCH
7566 JONES 2975 2 20 RESEARCH
7654 MARTIN 1250 2 30 RESEARCH
7698 BLAKE 2850 2 30 RESEARCH
7782 CLARK 2450 2 10 RESEARCH
7788 SCOTT 3000 2 20 RESEARCH
7839 KING 5000 2 10 RESEARCH
7844 TURNER 1500 2 30 RESEARCH
7876 ADAMS 1100 2 20 RESEARCH
7900 JAMES 950 2 30 RESEARCH
7902 FORD 3000 2 20 RESEARCH

EMPNO ENAME SAL GRADE DEPTNO DNAME
———- ———- ———- ———- ———- ————–
7934 MILLER 1300 2 10 RESEARCH
7369 SMITH 800 3 20 RESEARCH
7499 ALLEN 1600 3 30 RESEARCH
7521 WARD 1250 3 30 RESEARCH
7566 JONES 2975 3 20 RESEARCH
7654 MARTIN 1250 3 30 RESEARCH
7698 BLAKE 2850 3 30 RESEARCH
7782 CLARK 2450 3 10 RESEARCH
7788 SCOTT 3000 3 20 RESEARCH
7839 KING 5000 3 10 RESEARCH
7844 TURNER 1500 3 30 RESEARCH
7876 ADAMS 1100 3 20 RESEARCH
7900 JAMES 950 3 30 RESEARCH
7902 FORD 3000 3 20 RESEARCH
7934 MILLER 1300 3 10 RESEARCH
7369 SMITH 800 4 20 RESEARCH
7499 ALLEN 1600 4 30 RESEARCH
7521 WARD 1250 4 30 RESEARCH
7566 JONES 2975 4 20 RESEARCH
7654 MARTIN 1250 4 30 RESEARCH
7698 BLAKE 2850 4 30 RESEARCH
7782 CLARK 2450 4 10 RESEARCH
7788 SCOTT 3000 4 20 RESEARCH
7839 KING 5000 4 10 RESEARCH
7844 TURNER 1500 4 30 RESEARCH
7876 ADAMS 1100 4 20 RESEARCH
7900 JAMES 950 4 30 RESEARCH
7902 FORD 3000 4 20 RESEARCH
7934 MILLER 1300 4 10 RESEARCH
7369 SMITH 800 5 20 RESEARCH
7499 ALLEN 1600 5 30 RESEARCH
7521 WARD 1250 5 30 RESEARCH
7566 JONES 2975 5 20 RESEARCH
7654 MARTIN 1250 5 30 RESEARCH
7698 BLAKE 2850 5 30 RESEARCH
7782 CLARK 2450 5 10 RESEARCH
7788 SCOTT 3000 5 20 RESEARCH
7839 KING 5000 5 10 RESEARCH
7844 TURNER 1500 5 30 RESEARCH
7876 ADAMS 1100 5 20 RESEARCH
7900 JAMES 950 5 30 RESEARCH
7902 FORD 3000 5 20 RESEARCH
7934 MILLER 1300 5 10 RESEARCH
7369 SMITH 800 1 20 SALES
7499 ALLEN 1600 1 30 SALES
7521 WARD 1250 1 30 SALES
7566 JONES 2975 1 20 SALES
7654 MARTIN 1250 1 30 SALES
7698 BLAKE 2850 1 30 SALES
7782 CLARK 2450 1 10 SALES
7788 SCOTT 3000 1 20 SALES
7839 KING 5000 1 10 SALES
7844 TURNER 1500 1 30 SALES
7876 ADAMS 1100 1 20 SALES
7900 JAMES 950 1 30 SALES
7902 FORD 3000 1 20 SALES
7934 MILLER 1300 1 10 SALES
7369 SMITH 800 2 20 SALES
7499 ALLEN 1600 2 30 SALES
7521 WARD 1250 2 30 SALES
7566 JONES 2975 2 20 SALES
7654 MARTIN 1250 2 30 SALES
7698 BLAKE 2850 2 30 SALES
7782 CLARK 2450 2 10 SALES
7788 SCOTT 3000 2 20 SALES
7839 KING 5000 2 10 SALES
7844 TURNER 1500 2 30 SALES
7876 ADAMS 1100 2 20 SALES
7900 JAMES 950 2 30 SALES
7902 FORD 3000 2 20 SALES
7934 MILLER 1300 2 10 SALES
7369 SMITH 800 3 20 SALES
7499 ALLEN 1600 3 30 SALES
7521 WARD 1250 3 30 SALES
7566 JONES 2975 3 20 SALES
7654 MARTIN 1250 3 30 SALES
7698 BLAKE 2850 3 30 SALES
7782 CLARK 2450 3 10 SALES
7788 SCOTT 3000 3 20 SALES
7839 KING 5000 3 10 SALES
7844 TURNER 1500 3 30 SALES
7876 ADAMS 1100 3 20 SALES
7900 JAMES 950 3 30 SALES
7902 FORD 3000 3 20 SALES
7934 MILLER 1300 3 10 SALES
7369 SMITH 800 4 20 SALES
7499 ALLEN 1600 4 30 SALES
7521 WARD 1250 4 30 SALES
7566 JONES 2975 4 20 SALES
7654 MARTIN 1250 4 30 SALES
7698 BLAKE 2850 4 30 SALES
7782 CLARK 2450 4 10 SALES
7788 SCOTT 3000 4 20 SALES
7839 KING 5000 4 10 SALES
7844 TURNER 1500 4 30 SALES
7876 ADAMS 1100 4 20 SALES
7900 JAMES 950 4 30 SALES

EMPNO ENAME SAL GRADE DEPTNO DNAME
———- ———- ———- ———- ———- ————–
7902 FORD 3000 4 20 SALES
7934 MILLER 1300 4 10 SALES
7369 SMITH 800 5 20 SALES
7499 ALLEN 1600 5 30 SALES
7521 WARD 1250 5 30 SALES
7566 JONES 2975 5 20 SALES
7654 MARTIN 1250 5 30 SALES
7698 BLAKE 2850 5 30 SALES
7782 CLARK 2450 5 10 SALES
7788 SCOTT 3000 5 20 SALES
7839 KING 5000 5 10 SALES
7844 TURNER 1500 5 30 SALES
7876 ADAMS 1100 5 20 SALES
7900 JAMES 950 5 30 SALES
7902 FORD 3000 5 20 SALES
7934 MILLER 1300 5 10 SALES
7369 SMITH 800 1 20 OPERATIONS
7499 ALLEN 1600 1 30 OPERATIONS
7521 WARD 1250 1 30 OPERATIONS
7566 JONES 2975 1 20 OPERATIONS
7654 MARTIN 1250 1 30 OPERATIONS
7698 BLAKE 2850 1 30 OPERATIONS
7782 CLARK 2450 1 10 OPERATIONS
7788 SCOTT 3000 1 20 OPERATIONS
7839 KING 5000 1 10 OPERATIONS
7844 TURNER 1500 1 30 OPERATIONS
7876 ADAMS 1100 1 20 OPERATIONS
7900 JAMES 950 1 30 OPERATIONS
7902 FORD 3000 1 20 OPERATIONS
7934 MILLER 1300 1 10 OPERATIONS
7369 SMITH 800 2 20 OPERATIONS
7499 ALLEN 1600 2 30 OPERATIONS
7521 WARD 1250 2 30 OPERATIONS
7566 JONES 2975 2 20 OPERATIONS
7654 MARTIN 1250 2 30 OPERATIONS
7698 BLAKE 2850 2 30 OPERATIONS
7782 CLARK 2450 2 10 OPERATIONS
7788 SCOTT 3000 2 20 OPERATIONS
7839 KING 5000 2 10 OPERATIONS
7844 TURNER 1500 2 30 OPERATIONS
7876 ADAMS 1100 2 20 OPERATIONS
7900 JAMES 950 2 30 OPERATIONS
7902 FORD 3000 2 20 OPERATIONS
7934 MILLER 1300 2 10 OPERATIONS
7369 SMITH 800 3 20 OPERATIONS
7499 ALLEN 1600 3 30 OPERATIONS
7521 WARD 1250 3 30 OPERATIONS
7566 JONES 2975 3 20 OPERATIONS
7654 MARTIN 1250 3 30 OPERATIONS
7698 BLAKE 2850 3 30 OPERATIONS
7782 CLARK 2450 3 10 OPERATIONS
7788 SCOTT 3000 3 20 OPERATIONS
7839 KING 5000 3 10 OPERATIONS
7844 TURNER 1500 3 30 OPERATIONS
7876 ADAMS 1100 3 20 OPERATIONS
7900 JAMES 950 3 30 OPERATIONS
7902 FORD 3000 3 20 OPERATIONS
7934 MILLER 1300 3 10 OPERATIONS
7369 SMITH 800 4 20 OPERATIONS
7499 ALLEN 1600 4 30 OPERATIONS
7521 WARD 1250 4 30 OPERATIONS
7566 JONES 2975 4 20 OPERATIONS
7654 MARTIN 1250 4 30 OPERATIONS
7698 BLAKE 2850 4 30 OPERATIONS
7782 CLARK 2450 4 10 OPERATIONS
7788 SCOTT 3000 4 20 OPERATIONS
7839 KING 5000 4 10 OPERATIONS
7844 TURNER 1500 4 30 OPERATIONS
7876 ADAMS 1100 4 20 OPERATIONS
7900 JAMES 950 4 30 OPERATIONS
7902 FORD 3000 4 20 OPERATIONS
7934 MILLER 1300 4 10 OPERATIONS
7369 SMITH 800 5 20 OPERATIONS
7499 ALLEN 1600 5 30 OPERATIONS
7521 WARD 1250 5 30 OPERATIONS
7566 JONES 2975 5 20 OPERATIONS
7654 MARTIN 1250 5 30 OPERATIONS
7698 BLAKE 2850 5 30 OPERATIONS
7782 CLARK 2450 5 10 OPERATIONS
7788 SCOTT 3000 5 20 OPERATIONS
7839 KING 5000 5 10 OPERATIONS
7844 TURNER 1500 5 30 OPERATIONS
7876 ADAMS 1100 5 20 OPERATIONS
7900 JAMES 950 5 30 OPERATIONS
7902 FORD 3000 5 20 OPERATIONS
7934 MILLER 1300 5 10 OPERATIONS

280 rows selected.

SQL> clear screen
SQL> /

EMPNO ENAME SAL GRADE DEPTNO DNAME
———- ———- ———- ———- ———- ————–
7369 SMITH 800 1 20 ACCOUNTING
7499 ALLEN 1600 1 30 ACCOUNTING
7521 WARD 1250 1 30 ACCOUNTING
7566 JONES 2975 1 20 ACCOUNTING
7654 MARTIN 1250 1 30 ACCOUNTING
7698 BLAKE 2850 1 30 ACCOUNTING
7782 CLARK 2450 1 10 ACCOUNTING
7788 SCOTT 3000 1 20 ACCOUNTING
7839 KING 5000 1 10 ACCOUNTING
7844 TURNER 1500 1 30 ACCOUNTING
7876 ADAMS 1100 1 20 ACCOUNTING
7900 JAMES 950 1 30 ACCOUNTING
7902 FORD 3000 1 20 ACCOUNTING
7934 MILLER 1300 1 10 ACCOUNTING
7369 SMITH 800 2 20 ACCOUNTING
7499 ALLEN 1600 2 30 ACCOUNTING
7521 WARD 1250 2 30 ACCOUNTING
7566 JONES 2975 2 20 ACCOUNTING
7654 MARTIN 1250 2 30 ACCOUNTING
7698 BLAKE 2850 2 30 ACCOUNTING
7782 CLARK 2450 2 10 ACCOUNTING
7788 SCOTT 3000 2 20 ACCOUNTING
7839 KING 5000 2 10 ACCOUNTING
7844 TURNER 1500 2 30 ACCOUNTING
7876 ADAMS 1100 2 20 ACCOUNTING
7900 JAMES 950 2 30 ACCOUNTING
7902 FORD 3000 2 20 ACCOUNTING
7934 MILLER 1300 2 10 ACCOUNTING
7369 SMITH 800 3 20 ACCOUNTING
7499 ALLEN 1600 3 30 ACCOUNTING
7521 WARD 1250 3 30 ACCOUNTING
7566 JONES 2975 3 20 ACCOUNTING
7654 MARTIN 1250 3 30 ACCOUNTING
7698 BLAKE 2850 3 30 ACCOUNTING
7782 CLARK 2450 3 10 ACCOUNTING
7788 SCOTT 3000 3 20 ACCOUNTING
7839 KING 5000 3 10 ACCOUNTING
7844 TURNER 1500 3 30 ACCOUNTING
7876 ADAMS 1100 3 20 ACCOUNTING
7900 JAMES 950 3 30 ACCOUNTING
7902 FORD 3000 3 20 ACCOUNTING
7934 MILLER 1300 3 10 ACCOUNTING
7369 SMITH 800 4 20 ACCOUNTING
7499 ALLEN 1600 4 30 ACCOUNTING
7521 WARD 1250 4 30 ACCOUNTING
7566 JONES 2975 4 20 ACCOUNTING
7654 MARTIN 1250 4 30 ACCOUNTING
7698 BLAKE 2850 4 30 ACCOUNTING
7782 CLARK 2450 4 10 ACCOUNTING
7788 SCOTT 3000 4 20 ACCOUNTING
7839 KING 5000 4 10 ACCOUNTING
7844 TURNER 1500 4 30 ACCOUNTING
7876 ADAMS 1100 4 20 ACCOUNTING
7900 JAMES 950 4 30 ACCOUNTING
7902 FORD 3000 4 20 ACCOUNTING
7934 MILLER 1300 4 10 ACCOUNTING
7369 SMITH 800 5 20 ACCOUNTING
7499 ALLEN 1600 5 30 ACCOUNTING
7521 WARD 1250 5 30 ACCOUNTING
7566 JONES 2975 5 20 ACCOUNTING
7654 MARTIN 1250 5 30 ACCOUNTING
7698 BLAKE 2850 5 30 ACCOUNTING
7782 CLARK 2450 5 10 ACCOUNTING
7788 SCOTT 3000 5 20 ACCOUNTING
7839 KING 5000 5 10 ACCOUNTING
7844 TURNER 1500 5 30 ACCOUNTING
7876 ADAMS 1100 5 20 ACCOUNTING
7900 JAMES 950 5 30 ACCOUNTING
7902 FORD 3000 5 20 ACCOUNTING
7934 MILLER 1300 5 10 ACCOUNTING
7369 SMITH 800 1 20 RESEARCH
7499 ALLEN 1600 1 30 RESEARCH
7521 WARD 1250 1 30 RESEARCH
7566 JONES 2975 1 20 RESEARCH
7654 MARTIN 1250 1 30 RESEARCH
7698 BLAKE 2850 1 30 RESEARCH
7782 CLARK 2450 1 10 RESEARCH
7788 SCOTT 3000 1 20 RESEARCH
7839 KING 5000 1 10 RESEARCH
7844 TURNER 1500 1 30 RESEARCH
7876 ADAMS 1100 1 20 RESEARCH
7900 JAMES 950 1 30 RESEARCH
7902 FORD 3000 1 20 RESEARCH
7934 MILLER 1300 1 10 RESEARCH
7369 SMITH 800 2 20 RESEARCH
7499 ALLEN 1600 2 30 RESEARCH
7521 WARD 1250 2 30 RESEARCH
7566 JONES 2975 2 20 RESEARCH
7654 MARTIN 1250 2 30 RESEARCH
7698 BLAKE 2850 2 30 RESEARCH
7782 CLARK 2450 2 10 RESEARCH
7788 SCOTT 3000 2 20 RESEARCH
7839 KING 5000 2 10 RESEARCH
7844 TURNER 1500 2 30 RESEARCH
7876 ADAMS 1100 2 20 RESEARCH
7900 JAMES 950 2 30 RESEARCH
7902 FORD 3000 2 20 RESEARCH

EMPNO ENAME SAL GRADE DEPTNO DNAME
———- ———- ———- ———- ———- ————–
7934 MILLER 1300 2 10 RESEARCH
7369 SMITH 800 3 20 RESEARCH
7499 ALLEN 1600 3 30 RESEARCH
7521 WARD 1250 3 30 RESEARCH
7566 JONES 2975 3 20 RESEARCH
7654 MARTIN 1250 3 30 RESEARCH
7698 BLAKE 2850 3 30 RESEARCH
7782 CLARK 2450 3 10 RESEARCH
7788 SCOTT 3000 3 20 RESEARCH
7839 KING 5000 3 10 RESEARCH
7844 TURNER 1500 3 30 RESEARCH
7876 ADAMS 1100 3 20 RESEARCH
7900 JAMES 950 3 30 RESEARCH
7902 FORD 3000 3 20 RESEARCH
7934 MILLER 1300 3 10 RESEARCH
7369 SMITH 800 4 20 RESEARCH
7499 ALLEN 1600 4 30 RESEARCH
7521 WARD 1250 4 30 RESEARCH
7566 JONES 2975 4 20 RESEARCH
7654 MARTIN 1250 4 30 RESEARCH
7698 BLAKE 2850 4 30 RESEARCH
7782 CLARK 2450 4 10 RESEARCH
7788 SCOTT 3000 4 20 RESEARCH
7839 KING 5000 4 10 RESEARCH
7844 TURNER 1500 4 30 RESEARCH
7876 ADAMS 1100 4 20 RESEARCH
7900 JAMES 950 4 30 RESEARCH
7902 FORD 3000 4 20 RESEARCH
7934 MILLER 1300 4 10 RESEARCH
7369 SMITH 800 5 20 RESEARCH
7499 ALLEN 1600 5 30 RESEARCH
7521 WARD 1250 5 30 RESEARCH
7566 JONES 2975 5 20 RESEARCH
7654 MARTIN 1250 5 30 RESEARCH
7698 BLAKE 2850 5 30 RESEARCH
7782 CLARK 2450 5 10 RESEARCH
7788 SCOTT 3000 5 20 RESEARCH
7839 KING 5000 5 10 RESEARCH
7844 TURNER 1500 5 30 RESEARCH
7876 ADAMS 1100 5 20 RESEARCH
7900 JAMES 950 5 30 RESEARCH
7902 FORD 3000 5 20 RESEARCH
7934 MILLER 1300 5 10 RESEARCH
7369 SMITH 800 1 20 SALES
7499 ALLEN 1600 1 30 SALES
7521 WARD 1250 1 30 SALES
7566 JONES 2975 1 20 SALES
7654 MARTIN 1250 1 30 SALES
7698 BLAKE 2850 1 30 SALES
7782 CLARK 2450 1 10 SALES
7788 SCOTT 3000 1 20 SALES
7839 KING 5000 1 10 SALES
7844 TURNER 1500 1 30 SALES
7876 ADAMS 1100 1 20 SALES
7900 JAMES 950 1 30 SALES
7902 FORD 3000 1 20 SALES
7934 MILLER 1300 1 10 SALES
7369 SMITH 800 2 20 SALES
7499 ALLEN 1600 2 30 SALES
7521 WARD 1250 2 30 SALES
7566 JONES 2975 2 20 SALES
7654 MARTIN 1250 2 30 SALES
7698 BLAKE 2850 2 30 SALES
7782 CLARK 2450 2 10 SALES
7788 SCOTT 3000 2 20 SALES
7839 KING 5000 2 10 SALES
7844 TURNER 1500 2 30 SALES
7876 ADAMS 1100 2 20 SALES
7900 JAMES 950 2 30 SALES
7902 FORD 3000 2 20 SALES
7934 MILLER 1300 2 10 SALES
7369 SMITH 800 3 20 SALES
7499 ALLEN 1600 3 30 SALES
7521 WARD 1250 3 30 SALES
7566 JONES 2975 3 20 SALES
7654 MARTIN 1250 3 30 SALES
7698 BLAKE 2850 3 30 SALES
7782 CLARK 2450 3 10 SALES
7788 SCOTT 3000 3 20 SALES
7839 KING 5000 3 10 SALES
7844 TURNER 1500 3 30 SALES
7876 ADAMS 1100 3 20 SALES
7900 JAMES 950 3 30 SALES
7902 FORD 3000 3 20 SALES
7934 MILLER 1300 3 10 SALES
7369 SMITH 800 4 20 SALES
7499 ALLEN 1600 4 30 SALES
7521 WARD 1250 4 30 SALES
7566 JONES 2975 4 20 SALES
7654 MARTIN 1250 4 30 SALES
7698 BLAKE 2850 4 30 SALES
7782 CLARK 2450 4 10 SALES
7788 SCOTT 3000 4 20 SALES
7839 KING 5000 4 10 SALES
7844 TURNER 1500 4 30 SALES
7876 ADAMS 1100 4 20 SALES
7900 JAMES 950 4 30 SALES

EMPNO ENAME SAL GRADE DEPTNO DNAME
———- ———- ———- ———- ———- ————–
7902 FORD 3000 4 20 SALES
7934 MILLER 1300 4 10 SALES
7369 SMITH 800 5 20 SALES
7499 ALLEN 1600 5 30 SALES
7521 WARD 1250 5 30 SALES
7566 JONES 2975 5 20 SALES
7654 MARTIN 1250 5 30 SALES
7698 BLAKE 2850 5 30 SALES
7782 CLARK 2450 5 10 SALES
7788 SCOTT 3000 5 20 SALES
7839 KING 5000 5 10 SALES
7844 TURNER 1500 5 30 SALES
7876 ADAMS 1100 5 20 SALES
7900 JAMES 950 5 30 SALES
7902 FORD 3000 5 20 SALES
7934 MILLER 1300 5 10 SALES
7369 SMITH 800 1 20 OPERATIONS
7499 ALLEN 1600 1 30 OPERATIONS
7521 WARD 1250 1 30 OPERATIONS
7566 JONES 2975 1 20 OPERATIONS
7654 MARTIN 1250 1 30 OPERATIONS
7698 BLAKE 2850 1 30 OPERATIONS
7782 CLARK 2450 1 10 OPERATIONS
7788 SCOTT 3000 1 20 OPERATIONS
7839 KING 5000 1 10 OPERATIONS
7844 TURNER 1500 1 30 OPERATIONS
7876 ADAMS 1100 1 20 OPERATIONS
7900 JAMES 950 1 30 OPERATIONS
7902 FORD 3000 1 20 OPERATIONS
7934 MILLER 1300 1 10 OPERATIONS
7369 SMITH 800 2 20 OPERATIONS
7499 ALLEN 1600 2 30 OPERATIONS
7521 WARD 1250 2 30 OPERATIONS
7566 JONES 2975 2 20 OPERATIONS
7654 MARTIN 1250 2 30 OPERATIONS
7698 BLAKE 2850 2 30 OPERATIONS
7782 CLARK 2450 2 10 OPERATIONS
7788 SCOTT 3000 2 20 OPERATIONS
7839 KING 5000 2 10 OPERATIONS
7844 TURNER 1500 2 30 OPERATIONS
7876 ADAMS 1100 2 20 OPERATIONS
7900 JAMES 950 2 30 OPERATIONS
7902 FORD 3000 2 20 OPERATIONS
7934 MILLER 1300 2 10 OPERATIONS
7369 SMITH 800 3 20 OPERATIONS
7499 ALLEN 1600 3 30 OPERATIONS
7521 WARD 1250 3 30 OPERATIONS
7566 JONES 2975 3 20 OPERATIONS
7654 MARTIN 1250 3 30 OPERATIONS
7698 BLAKE 2850 3 30 OPERATIONS
7782 CLARK 2450 3 10 OPERATIONS
7788 SCOTT 3000 3 20 OPERATIONS
7839 KING 5000 3 10 OPERATIONS
7844 TURNER 1500 3 30 OPERATIONS
7876 ADAMS 1100 3 20 OPERATIONS
7900 JAMES 950 3 30 OPERATIONS
7902 FORD 3000 3 20 OPERATIONS
7934 MILLER 1300 3 10 OPERATIONS
7369 SMITH 800 4 20 OPERATIONS
7499 ALLEN 1600 4 30 OPERATIONS
7521 WARD 1250 4 30 OPERATIONS
7566 JONES 2975 4 20 OPERATIONS
7654 MARTIN 1250 4 30 OPERATIONS
7698 BLAKE 2850 4 30 OPERATIONS
7782 CLARK 2450 4 10 OPERATIONS
7788 SCOTT 3000 4 20 OPERATIONS
7839 KING 5000 4 10 OPERATIONS
7844 TURNER 1500 4 30 OPERATIONS
7876 ADAMS 1100 4 20 OPERATIONS
7900 JAMES 950 4 30 OPERATIONS
7902 FORD 3000 4 20 OPERATIONS
7934 MILLER 1300 4 10 OPERATIONS
7369 SMITH 800 5 20 OPERATIONS
7499 ALLEN 1600 5 30 OPERATIONS
7521 WARD 1250 5 30 OPERATIONS
7566 JONES 2975 5 20 OPERATIONS
7654 MARTIN 1250 5 30 OPERATIONS
7698 BLAKE 2850 5 30 OPERATIONS
7782 CLARK 2450 5 10 OPERATIONS
7788 SCOTT 3000 5 20 OPERATIONS
7839 KING 5000 5 10 OPERATIONS
7844 TURNER 1500 5 30 OPERATIONS
7876 ADAMS 1100 5 20 OPERATIONS
7900 JAMES 950 5 30 OPERATIONS
7902 FORD 3000 5 20 OPERATIONS
7934 MILLER 1300 5 10 OPERATIONS

280 rows selected.

SQL> ed
Wrote file afiedt.buf

1 select empno,ename,sal,grade,emp.deptno,dname
2* from emp,dept,salgrade
3
SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 select empno,ename,sal,emp.deptno,dname
2 from emp,dept
3* where emp.deptno=dept.deptno
SQL> /

EMPNO ENAME SAL DEPTNO DNAME
———- ———- ———- ———- ————–
7369 SMITH 800 20 RESEARCH
7499 ALLEN 1600 30 SALES
7521 WARD 1250 30 SALES
7566 JONES 2975 20 RESEARCH
7654 MARTIN 1250 30 SALES
7698 BLAKE 2850 30 SALES
7782 CLARK 2450 10 ACCOUNTING
7788 SCOTT 3000 20 RESEARCH
7839 KING 5000 10 ACCOUNTING
7844 TURNER 1500 30 SALES
7876 ADAMS 1100 20 RESEARCH
7900 JAMES 950 30 SALES
7902 FORD 3000 20 RESEARCH
7934 MILLER 1300 10 ACCOUNTING

14 rows selected.

SQL> ed
Wrote file afiedt.buf

1 select empno,ename,sal,emp.deptno,dname
2 from emp,dept
3* where emp.deptno=dept.deptno
SQL>
SQL>
SQL>
SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.deptno,d.dname,d.loc
2 from emp e ,dept d
3* where d.loc=’NEW YORK’
4 /

EMPNO ENAME DEPTNO DNAME LOC
———- ———- ———- ————– ————-
7369 SMITH 20 ACCOUNTING NEW YORK
7499 ALLEN 30 ACCOUNTING NEW YORK
7521 WARD 30 ACCOUNTING NEW YORK
7566 JONES 20 ACCOUNTING NEW YORK
7654 MARTIN 30 ACCOUNTING NEW YORK
7698 BLAKE 30 ACCOUNTING NEW YORK
7782 CLARK 10 ACCOUNTING NEW YORK
7788 SCOTT 20 ACCOUNTING NEW YORK
7839 KING 10 ACCOUNTING NEW YORK
7844 TURNER 30 ACCOUNTING NEW YORK
7876 ADAMS 20 ACCOUNTING NEW YORK
7900 JAMES 30 ACCOUNTING NEW YORK
7902 FORD 20 ACCOUNTING NEW YORK
7934 MILLER 10 ACCOUNTING NEW YORK

14 rows selected.

SQL> clear screen
SQL> /

EMPNO ENAME DEPTNO DNAME LOC
———- ———- ———- ————– ————-
7369 SMITH 20 ACCOUNTING NEW YORK
7499 ALLEN 30 ACCOUNTING NEW YORK
7521 WARD 30 ACCOUNTING NEW YORK
7566 JONES 20 ACCOUNTING NEW YORK
7654 MARTIN 30 ACCOUNTING NEW YORK
7698 BLAKE 30 ACCOUNTING NEW YORK
7782 CLARK 10 ACCOUNTING NEW YORK
7788 SCOTT 20 ACCOUNTING NEW YORK
7839 KING 10 ACCOUNTING NEW YORK
7844 TURNER 30 ACCOUNTING NEW YORK
7876 ADAMS 20 ACCOUNTING NEW YORK
7900 JAMES 30 ACCOUNTING NEW YORK
7902 FORD 20 ACCOUNTING NEW YORK
7934 MILLER 10 ACCOUNTING NEW YORK

14 rows selected.

SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.deptno,d.dname,d.loc
2 from emp e ,dept d
3 where e.deptno=d.deptno and
4* d.loc=’NEW YORK’
5 /

EMPNO ENAME DEPTNO DNAME LOC
———- ———- ———- ————– ————-
7782 CLARK 10 ACCOUNTING NEW YORK
7839 KING 10 ACCOUNTING NEW YORK
7934 MILLER 10 ACCOUNTING NEW YORK

SQL> clear screen
SQL> /

EMPNO ENAME DEPTNO DNAME LOC
———- ———- ———- ————– ————-
7782 CLARK 10 ACCOUNTING NEW YORK
7839 KING 10 ACCOUNTING NEW YORK
7934 MILLER 10 ACCOUNTING NEW YORK

SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.deptno,d.dname,d.loc
2 from emp e ,dept d
3 where e.deptno=d.deptno and
4* d.loc=’NEW YORK’
SQL>
SQL> /

EMPNO ENAME DEPTNO DNAME LOC
———- ———- ———- ————– ————-
7782 CLARK 10 ACCOUNTING NEW YORK
7839 KING 10 ACCOUNTING NEW YORK
7934 MILLER 10 ACCOUNTING NEW YORK

SQL> clear screen
SQL> /

EMPNO ENAME DEPTNO DNAME LOC
———- ———- ———- ————– ————-
7782 CLARK 10 ACCOUNTING NEW YORK
7839 KING 10 ACCOUNTING NEW YORK
7934 MILLER 10 ACCOUNTING NEW YORK

SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.deptno,d.dname,d.loc
2 from emp e ,dept d
3 where e.deptno=d.deptno and
4* d.loc=’NEW YORK’
SQL>
SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.sal,s.grade
2 from emp e ,salgrade s
3* where e.empno=&eno
SQL> /
Enter value for eno: 7369
old 3: where e.empno=&eno
new 3: where e.empno=7369

EMPNO ENAME SAL GRADE
———- ———- ———- ———-
7369 SMITH 800 1
7369 SMITH 800 2
7369 SMITH 800 3
7369 SMITH 800 4
7369 SMITH 800 5

SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.sal,s.grade
2 from emp e ,salgrade s
3 where s.grade=1 and
4* e.empno=&eno
5 /
Enter value for eno: 7902
old 4: e.empno=&eno
new 4: e.empno=7902

EMPNO ENAME SAL GRADE
———- ———- ———- ———-
7902 FORD 3000 1

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.sal,s.grade
2 from emp e ,salgrade s
3 where s.grade=1 and
4* e.empno=&eno
5 /
Enter value for eno: 7369
old 4: e.empno=&eno
new 4: e.empno=7369

EMPNO ENAME SAL GRADE
———- ———- ———- ———-
7369 SMITH 800 1

SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.sal,s.grade
2 from emp e ,salgrade s
3 where s.grade=1 and
4* e.empno=&eno
SQL>
SQL> /
Enter value for eno: 7902
old 4: e.empno=&eno
new 4: e.empno=7902

EMPNO ENAME SAL GRADE
———- ———- ———- ———-
7902 FORD 3000 1

SQL> ed
Wrote file afiedt.buf

1 select e.empno,e.ename,e.sal,s.grade
2 from emp e ,salgrade s
3 where s.grade=1 and
4 e.empno=&eno and
5* e.sal between s.losal and s.hisal
SQL> /
Enter value for eno: 7369
old 4: e.empno=&eno and
new 4: e.empno=7369 and

EMPNO ENAME SAL GRADE
———- ———- ———- ———-
7369 SMITH 800 1

SQL> clear screen
SQL> /
Enter value for eno: 7902
old 4: e.empno=&eno and
new 4: e.empno=7902 and

no rows selected

SQL> clear screen
SQL> ed
Wrote file afiedt.buf

1 select e.ename,m.ename “Manager”
2 from emp e,emp m
3* where e.mgr=m.empno
SQL> /

ENAME Manager
———- ———-
FORD JONES
SCOTT JONES
JAMES BLAKE
ALLEN BLAKE
WARD BLAKE
TURNER BLAKE
MARTIN BLAKE
MILLER CLARK
ADAMS SCOTT
BLAKE KING
JONES KING
CLARK KING
SMITH FORD

13 rows selected.

SQL> clear screen
SQL> /

ENAME Manager
———- ———-
FORD JONES
SCOTT JONES
JAMES BLAKE
ALLEN BLAKE
WARD BLAKE
TURNER BLAKE
MARTIN BLAKE
MILLER CLARK
ADAMS SCOTT
BLAKE KING
JONES KING
CLARK KING
SMITH FORD

13 rows selected.

SQL> clear screen
SQL> exit