Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Module 1-DBMS

The document discusses a SQL lab module on basic operations like INSERT, ALTER, GROUP BY, COUNT, AVG, IN, DROP, and WHERE. It provides sample data for an Employee table with fields like ID, Name, Age, City, and Salary. It then lists 10 SQL queries to perform common operations on the table like inserting data, changing data types, renaming columns, counting records by city, finding average salaries, filtering records, adding and deleting columns, and renaming the table.

Uploaded by

laalpool69
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Module 1-DBMS

The document discusses a SQL lab module on basic operations like INSERT, ALTER, GROUP BY, COUNT, AVG, IN, DROP, and WHERE. It provides sample data for an Employee table with fields like ID, Name, Age, City, and Salary. It then lists 10 SQL queries to perform common operations on the table like inserting data, changing data types, renaming columns, counting records by city, finding average salaries, filtering records, adding and deleting columns, and renaming the table.

Uploaded by

laalpool69
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

DBMS Lab (PCS-503), B. Tech., CSE, 5th Sem.

 MODULE 1: INSERT, ALTER, GROUP BY, COUNT(), AVG(), IN, DROP, WHERE)

#Problem statement 1- Consider the given relational schema.

Employee(ID, Name, Age, City, Salary)

(a) For the above schema, set the data types along with constraints as per the following
(Hint—you need not modify the schema of a table for this, You only need to define the given
data types with constraints (if any) at the time of creation of the table).
1. For ID field, set the data type as Integer with PRIMARY KEY constraint. Moreover this field
is auto-incremented field. i.e., it will set the roll number automatically from 1 to 5. You need
not insert any value in this field manually.
2. For Name field, set the data type as VARCHAR(20) with NOT NULL Constraint.
3. For Age field, set the data type as Integer with ‘CHECK’ constraint by allowing only positive
value in this field.
4. For City field, set the data type as VARCHAR(20) with NOT NULL constraint.
5. For Salary field, set the data type as INT.

(b) By using the above schema perform the following SQL Queries.
1. Write a SQL query to insert the following into the table.
ID Name Age City Salary
1 JOHN 30 Dehradun 65000
. ALICE 27 Delhi 85000
. SIMMY 30 Dehradun 70000
. BOB 34 Dehradun 65000
5 DEEPTI 29 Mumbai 75000

2. Write a SQL query to change the data type of a column ‘Salary’ from INT to FLOAT.
3. Write a SQL query to rename the column name from ‘ID’ to ‘Emp_ID’
4. Write a SQL query to count the number of employee city-wise.
5. Write a SQL query to find the average salary of all the employees who belongs to city
Dehradun only.
6. Write a SQL query to display the employee details where name of the employee is
starting and ending with ‘J’ and ‘N’ respectively.
7. Write a SQL query to display all the employees who lives in city ‘Dehradun’ and ‘Mumbai’
8. Write a SQL query to add a new column named as ‘Designation’ with VARCHAR(20) data
type.
9. Write a SQL query to delete the column ‘Designation’ from the table.
10. Write a SQL query to change the table name from Employee to ‘Emp’.

You might also like