Exercise-1 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Exercise 1:

DDL Commands
1. Create a table employee (ename(30 chars), eid, edesignation(20 chars), ecity)
Perform the following queries
a) Describe the fields of the table. (hint: use sp_help command)
b) Add a new field named salary to the table and it must contain some values.
c) Modify the field edesignation so that it can accept upto 30 characters.
d) Insert 10 employee records.
e) Display the employee details.
f) Drop a column salary.
g) Rename the table. (hint: command sp_rename)
h) Delete all employee record from the table. (hint: use delete/truncate command)
i) Drop the table.

DML Commands
1. Create the following tables
Student (Rollno, Name, Deptname, Marks (of 4 Subjects), Total, Percentage.
Insert 10 student details.
a) Display the Student details.
b) Display the student names who got total greater than 300
c) Display the CSE department student names.
d) Display the student detail whose department is “it” and also percentage is greater than
or equal to 75.
e) Find the student details whose department is in Civil, Mech.
f) Select regno, name, grade, department, percentage of all students
g) Sort the student name in ascending order and descending order.
h) Drop the column rollno.

Additional Exercises

Table name: customer

customer_id | cust_name | city | grade | salesman_id


------------+----------------+------------+-------+------------
3002 | Nick Rimando | New York | 100 | 5001
3007 | Brad Davis | New York | 200 | 5001
3005 | Graham Zusi | California | 200 | 5002
3008 | Julian Green | London | 300 | 5002
3004 | Fabian Johnson | Paris | 300 | 5006
3009 | Geoff Cameron | Berlin | 100 | 5003
3003 | Jozy Altidor | Moscow | 200 | 5007
3001 | Brad Guzan | London | | 5005
 Write a query to display all customers with a grade above 100.   
 Write a query statement to display all customers in New York who have a grade value
above 100.    
 Write a SQL statement to display all customers, who are either belongs to the city New
York or had a grade above 100.    
 Write a SQL statement to display all the customers, who are either belongs to the city
New York or not had a grade above 100.    
 Write a SQL query to display those customers who are neither belongs to the city New
York nor grade value is more than 100.    

Exercise 1.2:
1. Create a table Student (Rollno, Name, Deptname, Marks (of 4 Subjects), Total, Percentage.
Insert 10 student details
Perform the following queries
j) Insert 10 employee records.
k) Display the department of all students without duplicates.
l) Select regno, name, grade, department, percentage of all students except those who
doesn’t have percentage in 75, 80 and 85.
m) Select the students who have percentage in the range between 70 and 90.
n) List out the departments with no of students present in the student table.

2. Create the following tables


Product(Proid,Proddesc,Price,Stock)
a) Describe the fields of the table.
b) Display the product details whose stock is <15.
c) Update the stock of all products by 10.
d) Display the product id.
e) List all products which start with either S or T.
f) Display the details when proid is given “P123”

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy