Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 24

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : K.Chandra Sekhar
Designation : Associate Lecturer
Branch : DCCP
Institute : Central Institute of Commerce,Tarnaka,
Hyd.
Year/Semester : V Semester
Subject : Relational Database Management System
Subject Code : CCP-505
Topic : Know the components of SQL
Duration : 50 Minutes
Sub-Topic : Write statements using the SQL Commands
Teaching Aids : PPT,Animation, Photographs
CCP505.37TO38 1
OBJECTIVES
On Completion of this period, you would be
able to know :

 How to write statements using the SQL Commands.

 Examples for Various SQL Commands.

CCP505.37TO38 2
RECAP

 Components of SQL
 Various components of SQL with syntax
 Various data types

CCP505.37TO38 3
Introduction
 What are data types
 What are SQL commands
 Usage of commands taking sample databases

CCP505.37TO38 4
SAMPLE DATA BASE
Data Base Name : STUDENT Table Name : STD_PER_DETAILS

Fig 1
CCP505.37TO38 5
SAMPLE DATA BASE
Data Base Name : STUDENT Table Name : STD_RESULTS

Fig 2 CCP505.37TO38 6
Structure of STUDENT Database Tables
Table Name : STD_PER_DETAILS

Field Name Data Type Size


admsn_no Number 5
rank Number 5
std_name Varchar2 20
f_name Varchar2 20
sex Char 1
DOB Date
cat Char 2
region Char 4
Fig 3

CCP505.37TO38 7
Structure of STUDENT Database
Tables

Table Name : STD_RESULTS

Field Name Data Type Size


rollno Number 5
pin Char 20
std_name Varchar2 20
sub1mark Number 3
sub2mark Number 3
sub3mark Number 3
sub4mark Number 3
sub5mark Fig 4 Number 3
CCP505.37TO38 8
CREATING TABLE STD_PER_DETAILS

CREATE TABLE STD_PER_DETAILS

(admsn_no number(5), rank number(5),

std_name varchar2(20), f_name varchar2(20),

sex char(1), DOB date, cat char(2), region char(4));

CCP505.37TO38 9
CREATING TABLE STD_RESULTS

CREATE TABLE STD_RESULTS

(rollno number(5), pin char(20), std_name varchar2(20),

sub1mark number(3), sub2mark number(3),

sub3mark number(3), sub4mark number(3),

sub5mark number(3));

CCP505.37TO38 10
ALTERING TABLESTD_PER_DETAILS
ALTER TABLE STD_PER_DETAILS

MODIFY

(region char(5));

CCP505.37TO38 11
ALTERING TABLE STD_PER_DETAILS

 ALTER TABLE STD_PER_DETAILS

ADD

phone number(15);

CCP505.37TO38 12
DROPPING TABLES

DROP TABLE STD_PER_DETAILS ;

DROP TABLE STD_RESULTS ;

CCP505.37TO38 13
INSERTing row(s) into STD-PER-DETAILS

INSERT INTO STD_PER_DETAILS

VALUES (1001,1008,’K.H.Siddesh’,’K.Ch.Sekhar’),

‘M’, to_date(‘8/7/1992’),’OC’,’AU’);

CCP505.37TO38 14
INSERTing row (s) into STD-RESULTS

INSERT INTO STD_RESULTS

VALUES (1,’06049-CCP-014’,’K.H.Siddesh’,

74, 68, 70, 64, 61);

CCP505.37TO38 15
UPDATE TABLES
 UPDATE STD_PER_DETAILS

SET region = ‘SVU’ WHERE rank = 1008 ;

 UPDATE STD_RESULTS

SET sub1mark = 80 WHERE rollno = 1;

CCP505.37TO38 16
DELETE RECORDS IN TABLES

DELETE FROM STD_PER_DETAILS

WHERE rank = 1008 ;

DELETE FROM STD_RESULTS

WHERE rollno = 1;

CCP505.37TO38 17
COMMIT
 SQL> COMMIT ;

 SQL> COMMIT step2 ;

CCP505.37TO38 18
ROLLBACK
 SQL> ROLLBACK ;

 SQL> ROLLBACK TO step3 ;

CCP505.37TO38 19
SAVEPOINT
 SQL> SAVEPOINT step3;

CCP505.37TO38 20
Summary

 Creating data bases


 Applying SQL commands to data bases

CCP505.37TO38 21
Quiz
1. Which is a DCL command
 Select
 Create
 Commit
 None of the above

Answer is : Commit

CCP505.37TO38 22
Frequently asked questions
1. Explain with syntax the following commands
a) Create
b) Insert
c) Update
d) Delete

CCP505.37TO38 23
Assignment
1. Create a Table with the following fields Empno,
Ename,Designation, Address .

2. Create a Table with the following fields Product name,


Price, Mfg Date, Qty .

CCP505.37TO38 24

You might also like