0% found this document useful (0 votes)
22 views8 pages

5 Oct 23

The document contains SQL commands and queries executed on an Oracle database. It creates tables, inserts sample data, and performs some queries. It creates tables like EMP, DEPT, SAL, EMP2, E_WORKER, E_MANAGER. It inserts records into these tables and runs queries to join and filter data between the tables. It encounters and resolves some errors during table creation and queries.

Uploaded by

iqbalsohaib38
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views8 pages

5 Oct 23

The document contains SQL commands and queries executed on an Oracle database. It creates tables, inserts sample data, and performs some queries. It creates tables like EMP, DEPT, SAL, EMP2, E_WORKER, E_MANAGER. It inserts records into these tables and runs queries to join and filter data between the tables. It encounters and resolves some errors during table creation and queries.

Uploaded by

iqbalsohaib38
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

SQL*Plus: Release 11.2.0.2.

0 Production on Thu Oct 5 09:21:18 2023

Copyright (c) 1982, 2014, Oracle. All rights reserved.

SQL> connect system;


Enter password:
Connected.
SQL> desc dept;
ERROR:
ORA-04043: object dept does not exist

SQL> create table emp


2 (
3 emp_id number(10),
4 emp_name varchar2(50),
5 emp_loc varchar2(40));

Table created.

SQL> insert into emp values(1,'Imran','Mianwali');

1 row created.

SQL> insert into emp values(2,'Mueed','Faisalabad');

1 row created.

SQL> insert into emp values(3,'AbdulRahman','Multan');

1 row created.

SQL> select d.deptname,e.ename from team1_department, emp e;


select d.deptname,e.ename from team1_department, emp e
*
ERROR at line 1:
ORA-00904: "E"."ENAME": invalid identifier

SQL> select d.deptname,e.emp_name from team1_department, emp e;


select d.deptname,e.emp_name from team1_department, emp e
*
ERROR at line 1:
ORA-00904: "D"."DEPTNAME": invalid identifier

SQL> desc team1_department;


Name Null? Type
----------------------------------------- -------- ----------------------------
DEPTNO NUMBER(10)
DEPTNAME VARCHAR2(50)
LOC VARCHAR2(50)

SQL> select d.deptname,e.emp_name from team1_department d, emp e;

DEPTNAME
--------------------------------------------------
EMP_NAME
--------------------------------------------------
Accounting
Imran

Accounting
Mueed

Accounting
AbdulRahman

DEPTNAME
--------------------------------------------------
EMP_NAME
--------------------------------------------------
Research
Imran

Research
Mueed

Research
AbdulRahman

DEPTNAME
--------------------------------------------------
EMP_NAME
--------------------------------------------------
SALES
Imran

SALES
Mueed

SALES
AbdulRahman

9 rows selected.

SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> select d.deptname,e.emp_name from team1_department d, emp e;

DEPTNAME
--------------------------------------------------
EMP_NAME
--------------------------------------------------
Accounting
Imran

Accounting
Mueed

Accounting
AbdulRahman

DEPTNAME
--------------------------------------------------
EMP_NAME
--------------------------------------------------
Research
Imran

Research
Mueed

Research
AbdulRahman

DEPTNAME
--------------------------------------------------
EMP_NAME
--------------------------------------------------
SALES
Imran

SALES
Mueed

SALES
AbdulRahman

9 rows selected.

SQL> select d.deptname,e.emp_name from team1_department d, emp e where


d.deptno=e.emp_id;

no rows selected

SQL> create table emp2(


2 eno number(10),ename varchar2(50),Sal varchar2(50));

Table created.

SQL> create table sal(


2 grade varchar2(50),losal varchar2(50),hisal varchar2(50));

Table created.

SQL> insert into sal values(1,700,1200)l;


insert into sal values(1,700,1200)l
*
ERROR at line 1:
ORA-00933: SQL command not properly ended

SQL> insert into sal values(1,700,1200);

1 row created.

SQL> insert into sal values(2,1201,1400);

1 row created.

SQL> insert into sal values(3,1401,2000);

1 row created.

SQL> insert into sal values(4,2001,3000);

1 row created.

SQL> insert into sal values(5,3001,9999);

1 row created.

SQL> insert into emp2 values(1,'abc',5000);

1 row created.

SQL> insert into emp2 values(2,'def',2850);

1 row created.

SQL> insert into emp2 values(3,'ghi',2450);

1 row created.

SQL> insert into emp2 values(4,'jkl',2775);

1 row created.

SQL> insert into emp2 values(5,'mno',1250);

1 row created.

SQL> select e.ename,e.sal,e.grade from emp2 e,grade g where e.sal between g.losal
and g.sal
2 ;
select e.ename,e.sal,e.grade from emp2 e,grade g where e.sal between g.losal and
g.sal
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> select e.ename,e.sal,e.grade from emp2 e,sal s where e.sal between s.losal and
s.sal
2 ;
select e.ename,e.sal,e.grade from emp2 e,sal s where e.sal between s.losal and
s.sal
*
ERROR at line 1:
ORA-00904: "S"."SAL": invalid identifier

SQL> select e.ename,e.sal,e.grade from emp2 e,sal s where e.sal between s.losal and
s.hisal;
select e.ename,e.sal,e.grade from emp2 e,sal s where e.sal between s.losal and
s.hisal
*
ERROR at line 1:
ORA-00904: "E"."GRADE": invalid identifier

SQL> select e.ename,e.sal,s.grade from emp2 e,sal s where e.sal between s.losal and
s.hisal;

ENAME
--------------------------------------------------
SAL
--------------------------------------------------
GRADE
--------------------------------------------------
abc
5000
5

def
2850
4

ENAME
--------------------------------------------------
SAL
--------------------------------------------------
GRADE
--------------------------------------------------

ghi
2450
4

jkl
2775

ENAME
--------------------------------------------------
SAL
--------------------------------------------------
GRADE
--------------------------------------------------
4

mno
1250
2

SQL> create table e_worker


2 emp_no NUMBER(50),
3 emp_name VARCHAR(50),
4 mgr NUMBER(10);
emp_no NUMBER(50),
*
ERROR at line 2:
ORA-00922: missing or invalid option

SQL> create table e_worker


2 (
3 emp_no NUMBER(10),
4 emp_name VARCHAR(50),
5 mgr NUMBER(10)
6 );

Table created.

SQL> insert into e_worker values(7698,'Blake',7839);

1 row created.

SQL> insert into e_worker values(7782,'clark',7839);

1 row created.

SQL> insert into e_worker values(7566,'jones',7839);

1 row created.

SQL> insert into e_worker values(7654,'martin',7839);

1 row created.

SQL> insert into e_worker values(7499,'aleen',7839);

1 row created.

SQL> create table e_manager


2 ;

*
ERROR at line 2:
ORA-00906: missing left parenthesis

SQL> drop table e_worker


2 ;

Table dropped.

SQL> create table e_worker


2 emp_no NUMBER(50),
3 emp_name VARCHAR(50),
4 mgr NUMBER(10);
emp_no NUMBER(50),
*
ERROR at line 2:
ORA-00922: missing or invalid option
SQL> create table e_worker
2 (
3 emp_no NUMBER(50),
4 emp_name VARCHAR(50),
5 mgr NUMBER(10)
6 );
emp_no NUMBER(50),
*
ERROR at line 3:
ORA-01727: numeric precision specifier is out of range (1 to 38)

SQL> create table e_worker


2 (
3 emp_no NUMBER(10),
4 emp_name VARCHAR(50),
5 mgr NUMBER(10)
6 );

Table created.

SQL> insert into e_worker values(7839,'king');


insert into e_worker values(7839,'king')
*
ERROR at line 1:
ORA-00947: not enough values

SQL> insert into e_worker values(7839,'king','');

1 row created.

SQL> insert into e_worker values(7698,'Blake',7839);

1 row created.

SQL> insert into e_worker values(7782,'clark',7839);

1 row created.

SQL> insert into e_worker values(7566,'jones',7839);

1 row created.

SQL> insert into e_worker values(7654,'martin',7839);

1 row created.

SQL> insert into e_worker values(7499,'aleen',7839);

1 row created.

SQL> create table e_manager


2 (
3 emp_no NUMBER(10),
4 emp_name VARCHAR2(50)
5 );
Table created.

SQL> insert into e_worker values(7839,'king');


insert into e_worker values(7839,'king')
*
ERROR at line 1:
ORA-00947: not enough values

SQL> insert into e_manager values(7839,'king');

1 row created.

SQL> insert into e_manager values(7839,'king');

1 row created.

SQL> insert into e_manager values(7839,'king');

1 row created.

SQL> insert into e_manager values(7839,'blake');

1 row created.

SQL> insert into e_manager values(7839,'blake');

1 row created.

SQL> desc

You might also like