Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SHAKARPUR, DELHI-110092
Govt. of NCT of Delhi,
DBMS PRACTICAL
FILE
Database Structure
Table name -> ITEMS
Attributes: - id – Primary key, name, cost, seller, id, bids
CUSTOMERS TABLE DATA RECORDS
ITEMS TABLE DATA RECORDS
PRACTICAL-1
The SELECT statement is used to select data from a database. The result is stored in a result table,
called the result-set.
OUTPUT
PRACTICAL -3
Theory: - The AND & OR operators are used to filter records based on more than one condition.
The AND operator displays a record if both the first condition AND the second condition are true.
The OR operator displays a record if either the first condition OR the second condition is true.
Query: - SELECT name, state, city FROM customers WHERE state='CA' AND city =
‘Riverside’;
OUTPUT
PRACTICAL-5
Ex: new% - this will search everything that starts with new.
Query: - SELECT city FROM customers WHERE city LIKE ‘h%d’;
OUTPUT
PRACTICAL-7
OUTPUT
PRACTICAL-8
Aim: - Functions
Theory: - count, sum, avg, max, min and list it doesn’t handle NULL in the same way as
ordinary function and operation instead of returning NULL operations is encountered, they only
take non- null fields into consideration while computing the outcome.
Query: - SELECT COUNT (*) AS item_count, MAX(cost) AS max, AVG(cost) AS avg FROM
items WHERE seller_id=12;
OUTPUT
PRACTICAL-10
Aim: - To Use Group by Function
Theory: - Group by clause is used in collaboration with SELECT statement to arrange identical
data in groups.
Query: - SELECT seller_id, COUNT (*) AS item_count FROM item GROUP BY seller id;
OUTPUT
PRACTICAL-11
OUTPUT
Query: - SELECT name, MIN (cost) FROM items WHERE name LIKE ‘%boxes of frogs’
AND seller_id IN (SELECT seller_id FROM items WHERE name LIKE ‘%boxes of frogs’);
OUTPUT
PRACTICAL-12
OUTPUT
Query: - SELECT customers.name, items.name FROM customers LEFT OUTER JOIN
items ON customers.id = items.seller_id;
OUTPUT
PRACTICAL-13
Aim: - Use of UNION.
Theory: - Database is collection of related data and data is collection of facts and figures that can
be processed to produce the information.
SQL is structured query language which is a computer language for storing, manipulating and
retrieving data stored in relational databases.
Query: - SELECT name, cost, bids FROM items WHERE bids > 190;
OUTPUT
PRACTICAL-14
OUTPUT
Query: - SELECT name, cost FROM items WHERE MATCH (name) Against (‘baby’);
OUTPUT
Query: - SELECT name, cost FROM items WHERE MATCH (name) against
(‘+baby_coat’ IN boolean MODE);
OUTPUT
PRACTICAL-15
OUTPUT
Query: - INSERT INTO ITEMS (id, name, cost, seller_id, bids) VALUES (‘1095’, ‘FISH N
CHOPS’, ‘8’, ‘63’, ‘20’), (‘1058’, ‘PASTRY’, ‘9’, ‘64’, ‘2’), (‘1049’, ‘COLD DRINK’, ‘2’, ‘5’,
‘8’);
OUTPUT
PRACTICAL-16
Query: - CREATE TABLE users (id int, username varchar(30), password varchar(20)
PRIMARY KEY(id));
OUTPUT
PRACTICAL-17
OUTPUT
PRACTICAL-18
OUTPUT