0% found this document useful (0 votes)
2 views

pranavsql

This document is a summer training project file on SQL and RDBMS, submitted by Pranav Kumar. It covers topics such as SQL introduction, RDBMS, primary keys, advantages of SQL, SQL commands, and exercises related to SQL queries. The document serves as a comprehensive guide for understanding and utilizing SQL in database management.

Uploaded by

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

pranavsql

This document is a summer training project file on SQL and RDBMS, submitted by Pranav Kumar. It covers topics such as SQL introduction, RDBMS, primary keys, advantages of SQL, SQL commands, and exercises related to SQL queries. The document serves as a comprehensive guide for understanding and utilizing SQL in database management.

Uploaded by

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

1

PRODUCT Re – engineering & Design


Summer Training Project File
(ST 201)

Submitted to: Submitted by:


Mrs Meenu Bhagat Pranav kumar
mam Roll No: SG22331
Semester – 2nd(CSE)

Computer Science & Engineering


University Institute of Engineering and
Technology
2

INDEX
SERIOL TOPIC PAGE DATE SIGN
NO NO

1 SQL introduction 3

2 RDBMS 4

3 PRIMARY KEY 4

4 ADVANTAGES OF SQL 6

5 SQL COMMANDS 6

6 SELECTION COMMANDS 11

7 EXERCISE - 1 16

8 EXERCISE - 2 24
3

SQL ( Structured Query Language )


DATA

A data can be defined as facts about something that can be used in calculating
, reasoning or planning.

INFORMATION
When the data is presented in an organised way that has some meaning for
the recipient is called information .

DATABASE
The organised collection of related data or related information which is related
to some specific domain is called database .

DBMS
DBMS stands for Database Management System . It can be defined as the
system to modify, handle and retrieve any type of data
▪ Uses of DBMS
1. It is used to access the data .
2. It is used to create the data .
3. It is used to update the data .
4. It is used to delete the data.

RDBMS
RDBMS is called Relational Data Base Management System and it is the basis for SQL
and for all the wanted database management systems like MySQL , MSSQL server ,
Oracle etc. The data in RDBMS is stored in data base objects which are called as tables
or Relation . It consists of numerous columns and rows . for example:

A B C D
4

TOUPLES
(rows in
RDBMS)

RELATION (table in
RDBMS)

NULL VALUE
The null value in a table is a value in a field that appears to be blank which
means a field with a null value is a field with no value.

A B C D
1 NULL 3 4
VALUE

PRIMARY KEY
Primary Key is the unique key which is applied to the columns in the table . The
column to which we are applying the primary key should have unique values
and no value in the column should be null . The primary key gives the
information about each and every row of the particular column , if the column
has any null value then the primary key will not be able to tell the information
about that particular row . All the values in the colum should be different
because if the values are identical then the primary key would not be able to
find the value of that row where that repeated value is present.
A B C D E F
1 201 null 111 11 45

2 201 121 123 222 23

3 222 123 23 11 45
5

Here in the above table column A can be considered as the primary key
because hare in this column all the values are unique.
When no column in the table has the unique value then we apply the
primary key to the group of two columns because there rows when
combine form the unique value so they can be considered as the primary
key.
A B C D

1 2 null 21
2001 2 12 null

1 301 13 22

Here in the above table , we cannot considered any column separately as


the primary key, but we can take the combination of column A and B , and
considered both of them jointly as the primary key.

SQL
SQL stands for Structured Query Language. It is used for storing ,
manipulating and retrieving the data stored in a relational database.

ADVANTAGES OF SQL
1. It allows the user to access the data in RDBMS .
2. It allows the user to describe the data.
3. It allows the user to define the data in the database and manipulate that
data.
4. It allows the user to create and drop database and tables.
5. It allows the user to create and view procedures and functions in the
database.
6. It allows the user to set condition on the tables and procedures .
6

7. It allow the user to add the new data and delete the previous data from the
database .
SQL COMMANDS
SQL commands are the instructions used to communicate with the
database to perform tasks , functions and queries with data. SQL commands
can be used to search the database and to do other functions like creating
tables , adding data to the table and dropping tables .

Syntax of some of the commands in SQL

a. Create table command


It is used to create the table. Its syntax is

CREATE TABLE table_name


(
Colum name 1 data type 1 ,
Column name 2 data type 2,
Column name 3 data type 3 ,
PRIMARY KEY (column_name)
);
The example program is given below :

b. Insert table command


It is used to insert values to the created table.
Its syntax is :
INSERT INTO table_name
( column 1,column 2,column3)
7

VALUES(value 1, value 2 , value 3);


The example program is given below

c. Alter table command


This is data definition language (DDL) command which is used to alter the
structure of the existing table . It is possible to add or delete columns .
Syntax of ADD alter command is given below:
ALTER TABLE table_name
ADD column_name;

The example program is given below:

Syntax of DROP table command


ALTER TABLE table_name
8

DROP column_name ;
The example program is given below:

4)DELETE COMMAND
Drop command removes the table structure and also its value. Delete
command only removes the rows of the table that satisfy the condition
provided by the “where” clause and return the number of records deleted.
Syntax of DROP command is given below:
DELETE FROM table_name
Where condition;
The example program is given below:
9

5)UPDATE COMMAND
Update command is used to modify the data values in a table . It is the DML
(data manipulation language)
The syntax of the update command is given below:
UPDATE table_name
Set column_name = new value
Where condition;
The example program is given below:

6) SELECT COMMAND
Select command is used for many different purposes. Some of the purposes of
the select command are given below:
a) For showing all the rows and columns
Syntax:
SELECT * FROM table_name ;
The example program is given below:
10

b) For selecting the particular column


Syntax:
SELECT column 1 , column 2 from table_name;
The example program is given below:

c) For retrieving the data based on the particular condition


Syntax:
Select * from table_name
Where condition ;
The example program is given below:
11

d) For retrieving the data from the particular column based on some
condition
Syntax:
SELECT column name FROM table_name
Where condition;
The example program is given below:

e) Using logical AND operator


Syntax :
SELECT column name from table_name
Where condition1 AND condition2;
The example program is given below:
12

E) For retrieving two columns in the output using logical AND operator
Syntax:
SELECT column1 , column2 from table_name
Where condition 1 AND condition 2;
The example program is given below:

f) Using logical OR operator


Syntax:
Select column name from table_name
Where codiion1 OR condition2;
The example program is given below:
13

g)For retrieving two columns in the output using logical OR operator


syntax:
Select column 1 , column 2 from table_name
Where codiion1 OR condition2;
The example program is given below:

7) ORDER BY COMMAND
We use the command ORDER BY to sort the data in the table .
Syntax :
SELECT * from table_name
ORDER BY column_name;
The example program is given below:
14

8) LIKE OPERATOR
It is used to show the columns names which have the like alphabets.
Syntax:
SELECT column_name from table_name
Where column name like a%;
The example program is given below:

a% -> all the names whose first letter is a.


_a% -> all the names whose second letter is a.
_a%_b% -> all the names whose second letter is a and fourth letter is b.
EXERCISE- 1
Ans 1 (a) Data for client master table
15

b) Data for the PRODUC_MATER table

C) Data for SALES_MASTER table:

Ans 2 ( a) Find out the names of all clients


16

(b) Retrieve the entire contents of CLIENT_MASTER table

(c) Retrieve the list of names , city , and state of all the clients

(d) List the various products available from product master table
17

e) List all the clients who are located in Mumbai

f)Find the names of the salesman who have a salary equal to Rs 3000.
18

Ans 3 (a) Change the city of ClientNo ‘C00005’ to ‘Bangalore’ .

(b) Change the BalDue of ClientNo ‘C0001’ to Rs 1000.


19

(C) Change the cost price of trousers to Rs 950.00

(d) Change the city of the salesman to Pune

Ans 4 Exercise on deleting records in a table


a)Delete all the salesman from the Salesman_Master whose saleries are equal
to Rs 3500.
20

(b) Delete all the products from the PRODUCT_MASTER where


the quantity on hand is equal to 100.

(C)Delete from the CLIENT_MASTER where the column state


holds the value ‘Tamil Nadu,.

( d) Add a column of Telephone to CLIENT_MASTER

Table with size 10.


21

e) destroy the table CLIENT MASTER

f)change the name of SALES_MASTER to sman_mast


22

EXERCISE – 2

1) Display all the records whose name starts with ‘John’.

2) Display all the records whose name ends with john .

3)Display all the records whos name have John (can be any
where)
23

4)Display all the records whose name starts with ‘A’ and ends
with ‘n’.

5) Display all the records where name has ‘no’ case sensitive .
24

6) Display all the records who got marks in nineties but not 100.

7)Display all the records who have alex or deo anywhere in the
name column .
25

8)Display all the records who have alex or john anywhere in the
colum .

9) Display all the records who have alex or John anywhere in the
column ,
26

10) Display all the records who have ro anywhere inside the
column and got the marks in nineties .

You might also like