You are on page 1of 22

 

 
DBMS & SQL
queries
10
 
Ashoka College of
Computer Education
|
1 row created.
FOR inserting
more values we
use ‘ ’ slash after
SQL> as be
low but after
above syntax
used:
SQL> / Enter value
for name: Vinay
Enter value for
roll_no: 08 Enter
value for class:
BCA Enter value
for address: Barnoti
old 1: insert into
student
values('&name','&r
oll_no','&class','&a
ddress') new 1:
insert into studen
values('Vinay','08','
BCA','Barnoti') 1
row created.
3)
 
FOR VIEWING
DATA IN THE
TABLE
: - Once data has
been inserted into
a table, the next
most logical
operation would
be to view what
has been inserted.
The SELECT SQL
verb is used to
achieve this. The
SELECT
command is used
to retrieve rows
selected from one
or more tables.
 
Syntax
:-
 SELECT * FROM
<table name>;
 
If we want to see all
the tables that are
already exist in the
database .we use
SELECT * FROM
TAB;
Example:-
SQL> select * from
student; NAME
ROLL_NO CLASS
ADDRESS
-----------------------
---------- ------------
---------- Prabhat 06
BCA Hatlimore
Kishore 01 BCA
Nagri Amarjeet 30
BCA airwan Vinay
08 BCA barnoti 1
row created.
When we use the
command
SELECT* FRM
TAB;
 the output is
displayed as:-
SQL> select * from
tab;
 

 
DBMS & SQL
queries
11
 
Ashoka College of
Computer Education
|
TNAME
TABTYPE
CLUSTERID
------------------------
------ -------
---------- ABC
TABLE ANKU
TABLE BONUS
TABLE
DEPARTMENTS
TABLE DEPT
TABLE EMP
TABLE
EMPLOYEE
TABLE
EMPLOYEES
TABLE
STUDENT
TABLE 9 rows
selected.
 
4)
 
ELIMINATION
OF DUPLICATE
ROWS
:-
A table could hold
duplicate rows in
such a case, only
unique rows the
distinct clause can
be used.
Syntax
: - SELECT
DISTINCT <column
name 1>,<column
name2> FROM
<table name> ;
 
This syntax will give
the unique values of
column 1 and
column 2.
Example
:-
SQL> select
distinct
name,roll_no from
student; NAME
ROLL_NO
--------------------
---------- Prabhat 06
Syntax:
-
SELECT
DISTINCT * from
<tablename>;
Example
:- SQL> Select
DISTINCT * from
student; NAME
ROLL_NO CLASS
ADDRESS
------------------
-------- ------------
---------- Prabhat 06
BCA Hatlimore
5)
 
SORTING DATA
IN A TABLE
: - Oracle allows
data from a table
to be viewed in
sorted order. The
rows retrieve from
the table will be
sorted either in
ascending or
descending order
depending on the
condition specified
in the select
sentence.
Syntax
: - SELECT *
FROM
<tablename>ORDE
R BY<column
name1>,<column
name 2> <[sort
order]>;
Example
:-
SQL> SELECT *
FROM STUDENT
ORDER BY name;
NAME ROLL_NO
CLASS ADDRESS

You might also like