0% found this document useful (0 votes)
25 views15 pages

New Practical

Uploaded by

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

New Practical

Uploaded by

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

create table Data(Name varchar2(20), Country varchar2(20));

Table created.

SQL> insert into Data values('&Name','&Country');

Enter value for name: Parth

Enter value for country: India

old 1: insert into Data values('&Name','&Country')

new 1: insert into Data values('Parth','India')

1 row created.

SQL> Nakul

SP2-0042: unknown command "Nakul" - rest of line ignored.

SQL> /

Enter value for name: Nakul

Enter value for country: Nigeria

old 1: insert into Data values('&Name','&Country')

new 1: insert into Data values('Nakul','Nigeria')

1 row created.

SQL> /

Enter value for name: Om

Enter value for country: India


old 1: insert into Data values('&Name','&Country')

new 1: insert into Data values('Om ','India')

1 row created.

SQL> /

Enter value for name: Tanmay

Enter value for country: India

old 1: insert into Data values('&Name','&Country')

new 1: insert into Data values('Tanmay','India')

1 row created.

SQL> /

Enter value for name: Piyush

Enter value for country: Nigeria

old 1: insert into Data values('&Name','&Country')

new 1: insert into Data values('Piyush','Nigeria')

1 row created.

SQL> /

Enter value for name: Aditya

Enter value for country: Nigeria

old 1: insert into Data values('&Name','&Country')


new 1: insert into Data values('Aditya','Nigeria')

1 row created.

SQL> /

Enter value for name: Rahul

Enter value for country: India

old 1: insert into Data values('&Name','&Country')

new 1: insert into Data values('Rahul','India')

1 row created.

SQL> SELECT *

2 FROM Customers

3 select * from data;

select * from data

ERROR at line 3:

ORA-00933: SQL command not properly ended

SQL> select * from data;

NAME COUNTRY

-------------------- --------------------
Parth India

Nakul Nigeria

Om India

Tanmay India

Piyush Nigeria

Aditya Nigeria

Rahul India

7 rows selected.

SQL> SELECT * FROM data WHERE Country = 'India ' OR Country = 'Nigeria';

NAME COUNTRY

-------------------- --------------------

Nakul Nigeria

Piyush Nigeria

Aditya Nigeria

SQL>

SQL> SELECT * FROM data WHERE NOT Country = 'Nigeria';

NAME COUNTRY

-------------------- --------------------

Parth India

Om India
Tanmay India

Rahul India

SQL> select COUNT(*) from data;

COUNT(*)

----------

select * from parth;

E_ID E_NAME E_SALARY D_ID

---------- -------------------- ---------- ----------

1 Parth 500 100

2 Nakul 1 200

3 Om 400 300

4 Tanmay 450 100

SQL> select * from dhake;

D_ID D_NAME

---------- --------------------

100 HR

200 SM

300 TL
SQL> select AVG(E_salary) from parth;

AVG(E_SALARY)

-------------

337.75

SQL> select SUM(E_salary) from parth;

SUM(E_SALARY)

-------------

1351

SQL> select MIN(E_salary) from parth;

MIN(E_SALARY)

-------------

SQL> select MAX(E_salary) from parth;

MAX(E_SALARY)

-------------

500
SQL> select COUNT(E_salary) from parth;

COUNT(E_SALARY)

---------------

SQL> select COUNT(*) from parth;

COUNT(*)

----------

SQL> commit;

Commit complete.

create table parth (E_id number(10),E_name varchar(20),E_salary number(15),D_id number(10));

Table created.

SQL> insert into parth values ('&E_id','&E_name','&E_salary','D_id');

Enter value for e_id: 01

Enter value for e_name: Parth

Enter value for e_salary: 50000

old 1: insert into parth values ('&E_id','&E_name','&E_salary','D_id')

new 1: insert into parth values ('01','Parth','50000','D_id')


insert into parth values ('01','Parth','50000','D_id')

ERROR at line 1:

ORA-01722: invalid number

SQL> insert into parth values ('&E_id','&E_name','&E_salary','&D_id');

Enter value for e_id: 01

Enter value for e_name: Parth

Enter value for e_salary: 500

Enter value for d_id: 100

old 1: insert into parth values ('&E_id','&E_name','&E_salary','&D_id')

new 1: insert into parth values ('01','Parth','500','100')

1 row created.

SQL> /

Enter value for e_id: 02

Enter value for e_name: Nakul

Enter value for e_salary: 01

Enter value for d_id: 200

old 1: insert into parth values ('&E_id','&E_name','&E_salary','&D_id')

new 1: insert into parth values ('02','Nakul','01','200')

1 row created.
SQL> /

Enter value for e_id: 03

Enter value for e_name: Om

Enter value for e_salary: 400

Enter value for d_id: 300

old 1: insert into parth values ('&E_id','&E_name','&E_salary','&D_id')

new 1: insert into parth values ('03','Om','400','300')

1 row created.

SQL> /

Enter value for e_id: 04

Enter value for e_name: Tanmay

Enter value for e_salary: 450

Enter value for d_id: 100

old 1: insert into parth values ('&E_id','&E_name','&E_salary','&D_id')

new 1: insert into parth values ('04','Tanmay','450','100')

1 row created.

SQL> select * from parth;

E_ID E_NAME E_SALARY D_ID

---------- -------------------- ---------- ----------


1 Parth 500 100

2 Nakul 1 200

3 Om 400 300

4 Tanmay 450 100

SQL> commit;

Commit complete.

SQL> create table dhake (D_id number(10),D_name varchar2(20));

Table created.

SQL> insert into dhake values('&D_id','&D_name');

Enter value for d_id: 100

Enter value for d_name: HR

old 1: insert into dhake values('&D_id','&D_name')

new 1: insert into dhake values('100','HR')

1 row created.

SQL> /

Enter value for d_id: 200

Enter value for d_name: SM

old 1: insert into dhake values('&D_id','&D_name')


new 1: insert into dhake values('200','SM')

1 row created.

SQL> /

Enter value for d_id: 300

Enter value for d_name: TL

old 1: insert into dhake values('&D_id','&D_name')

new 1: insert into dhake values('300','TL')

1 row created.

SQL> commit;

Commit complete.

SQL> select * from dhake;

D_ID D_NAME

---------- --------------------

100 HR

200 SM

300 TL

SQL> select parth.E_id,parth.E_name,parth.E_salary,parth.D_id,dhake.D_name


2 FROM parth

3 INNER JOIN dhake ON parth.D_id=dhake.D_id;

E_ID E_NAME E_SALARY D_ID D_NAME

---------- -------------------- ---------- ---------- --------------------

1 Parth 500 100 HR

2 Nakul 1 200 SM

3 Om 400 300 TL

4 Tanmay 450 100 HR

create table parth1(E_id number(10),E_name varchar(20),E_salary number(15),D_id number(10));

Table created.

SQL> > insert into parth1 values ('&E_id','&E_name','&E_salary','D_id');

SP2-0734: unknown command beginning "> insert i..." - rest of line ignored.

SQL> insert into parth1 values ('&E_id','&E_name','&E_salary','D_id');

Enter value for e_id: 1

Enter value for e_name: Parth

Enter value for e_salary: 5000

old 1: insert into parth1 values ('&E_id','&E_name','&E_salary','D_id')

new 1: insert into parth1 values ('1','Parth','5000','D_id')

insert into parth1 values ('1','Parth','5000','D_id')

ERROR at line 1:
ORA-01722: invalid number

SQL> insert into parth1 values ('&E_id','&E_name','&E_salary','&D_id');

Enter value for e_id: 1

Enter value for e_name: Parth

Enter value for e_salary: 5000

Enter value for d_id: 100

old 1: insert into parth1 values ('&E_id','&E_name','&E_salary','&D_id')

new 1: insert into parth1 values ('1','Parth','5000','100')

1 row created.

SQL> /

Enter value for e_id: 2

Enter value for e_name: Nakul

Enter value for e_salary: 4500

Enter value for d_id: 200

old 1: insert into parth1 values ('&E_id','&E_name','&E_salary','&D_id')

new 1: insert into parth1 values ('2','Nakul','4500','200')

1 row created.

SQL> /

Enter value for e_id: 3


Enter value for e_name: Tanmay

Enter value for e_salary: 4750

Enter value for d_id: 300

old 1: insert into parth1 values ('&E_id','&E_name','&E_salary','&D_id')

new 1: insert into parth1 values ('3','Tanmay','4750','300')

1 row created.

SQL> select * from parth1;

E_ID E_NAME E_SALARY D_ID

---------- -------------------- ---------- ----------

1 Parth 5000 100

2 Nakul 4500 200

3 Tanmay 4750 300

SQL> select parth1.E_id,parth1.E_name,parth1.E_salary,parth1.D_id

2 from parth1

3 left join dhake

4 ON parth1.D_id=dhake.D_id;

E_ID E_NAME E_SALARY D_ID

---------- -------------------- ---------- ----------

1 Parth 5000 100

2 Nakul 4500 200


3 Tanmay 4750 300

You might also like