DBMS
BCA
3RD SEMESTER
SUBMITTED BY: Tejus Tagra
ENROLLMENT NO: A25304824020
SUBMITTED TO: DR. PARAMPREET KAUR
INDEX
S.NO TITLE REMARKS
1 Write a Query to create a table in SQL.
2 Write a Query to display structure of table
in SQL.
3 Write a Query to insert a row in table.
4 Write a Query to display roll number and
name from table.
5 Write a Query to add gender in table
student.
6 Write a Query to modify data type in table.
7 Write a Query to update branch of student
in table.
8 Write a Query to delete entry in a table.
9 Write a Query to rename column in table.
10 Write a Query to rename table in SQL.
11 Write a Query to use Drop Statement.
12 Write a Query to sort entries in a table
using Order By clause.
13 Write a Query to use aggregate functions in
SQL.
S.NO TITLE REMARKS
14 Use of substring comparison.
15 Use of order by statement.
16 Write a Query to insert a row in table.
17 Write a Query to display roll number and
name from table.
18 Write a Query to add gender in table
student.
19 Write a Query to modify data type in table.
20 Write a Query to update branch of student
in table.
21 Write a Query to delete entry in a table.
22 Write a Query to rename column in table.
23 Write a Query to rename table in SQL.
24 Write a Query to use Drop Statement.
25 Write a Query to sort entries in a table
using Order By clause.
26 Write a Query to use aggregate functions in
SQL.
Q1. Write a Query to create a table in SQL.
CODE:
CREATE TABLE student
(
RollNo INT PRIMARY KEY,
Name VARCHAR(20),
Branch VARCHAR(10)
);
OUTPUT:
Q2. Write a Query to display structure of table in SQL.
CODE:
DESC student;
OUTPUT:
Q3. Write a Query to insert a row in table.
CODE:
INSERT INTO student (RollNo, Name, Branch)
VALUES (1, 'Samridh', 'BCA');
OUPUT:
Q4. Write a Query to display roll number and name from table.
CODE:
SELECT ROLLNO, NAME FROM student;
OUTPUT:
Q5. Write a Query to add gender in table student.
CODE:
ALTER TABLE STUDENT ADD GENDER VARCHAR(10);
OUTPUT:
Q6. Write a Query to modify data type in table.
CODE:
ALTER TABLE student MODIFY NAME VARCHAR(30);
ALTER TABLE student MODIFY ROLLNO VARCHAR(5);
OUTPUT:
Q7. Write a Query to update branch of student in table.
CODE:
UPDATE student SET BRANCH='BTECH' WHERE
ROLLNO=1;
OUTPUT:
Q8. Write a Query to delete entry in a table.
CODE:
DELETE FROM student WHERE ROLLNO=1;
OUTPUT:
Q9. Write a Query to rename column in table.
CODE:
ALTER TABLE student RENAME COLUMN NAME TO
STUDENT_NAME;
OUTPUT:
Q10. Write a Query to rename table in SQL.
CODE:
ALTER TABLE student RENAME TO STUDENT_DETAILS;
OUTPUT:
Q11. Write a Query to use Drop Statement.
CODE:
DROP TABLE STUDENT_DETAILS;
OUTPUT:
Q12. Write a Query to sort entries in a table using Order By
clause.
CODE:
SELECT * FROM STUDENT ORDER BY ROLLNO DESC;
OUTPUT:
Q13. Write a Query to use aggregate functions in SQL.
CODE:
COUNT: SELECT COUNT(*) AS ROLLNO FROM STUDENT;
SUM: SELECT SUM(MARKS) AS MARKS FROM STUDENT;
AVG: SELECT AVG(MARKS) AS MARKS FROM STUDENT;
MIN: SELECT MIN(MARKS) AS MARKS FROM STUDENT;
MAX: SELECT MAX(MARKS) AS MARKS FROM STUDENT;