Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Q.1) Choose the correct option to complete the sentence.

(6M)
1) To indicate that there should be 6 integers and 2 decimal positions we use ____.
a) DECIMAL(8,2) b) DECIMAL(6,2) c) DECIMAL(2,6) d) DECIMAL(2,8)
2) To Save the transaction we use _____.
a) Rollback b) Save c) Commit d) Return
3) A Database contains one or more ______.
a) Rows b) Databases c) Columns d) Tables
4) To make changes in the data already entered in the table we use ____.
a) Alter table b) Update & set c) Select d) Create
5) The clause used to arrange the rows in the table is ______.
a) Arrange By b) Sort By c) Order By d) Display By
6) The query Select * from department; will display _______ the rows in the table department.
a) First row b) Last row c) Middle two row d) All

Q.2) State whether the following statements are True or False.(4M)


1) Two columns of a table can have same name.
2) MySQL is not case sensitive by default.
3) Primary key column always will have unique values.
4) In a table you can have two candidate keys.

Q.3) Answer the following.(Any Five)(1M Each)


1) How many types f relationships available? Name them.
2) What do you understand by Primary Key?
3) Write query to display all databases where database name starts with 'M'.
4) Which function is used to find the size of a string?
5) Which function is used to find remainder of a division?
6) Which function is used to return the name of weekday for a date?
7) Which function is used to remove blank spaces from the left hand side?

Q.4) Answer the following.(Any Five) (3M Each)


1) Explain the following built-in functions in MYSQL;
a) ROUND() b) MOD() c) UPPER() d) LTRIM() e) MID() f) MONTH()
g) RIGHT() h) REVERSE() i) ABS()
2) Write MYSQL statement to create a table called ADMISSION having the following columns
Roll Numbers (RNO, integer, should be increased by 1 automatically), Student Name
(SNAME, character with variable width 25), Gender (GENEDER, Boolean), Date of birth
(DOB, Date) and Paid Fees (FEES, 5 integers and 2 decimals, should not be empty).
3) Write MYSQL statement to create a table BILL having the following columns Bill Number (BN,
smallint, primary key), Product Name (PRNAME, character with variable width 15 columns),
Quantity (QTY, integer, positive) and Amount (AMT, 6 integers and 2 decimals, should not be
empty).
4) There exists a table called ATTEND containing the columns student name (SNAME,
character), class (CLASS, character), division (DIV, character) and no. of lectures attended
(TOTAL_LEC, numeric). Write MySQL statements statements for the following;
a) Add a new column for roll number (ROLL, integer) as first column the table.
b) Display all the rows arranged in ascending order of the students name of the table.
d) Rename the table as ‘ATTD REPORT’.
5) There exists a table called COLLEGE having the following columns Student Name (SNAME,
character), Class (CLASS, character), Division (DIV, character) and Number of lectures
attended (LEC, numeric). Write MYSQL Statements for the following;
a) Add a new column Roll Number (RNO, integer) as the first column of the table.
b) Increase the number of lectures attended by 2 for all the students.
c) Delete all the rows where division is ‘C’.
d) Display the structure of table COLLEGE.
e) Delete the column DIV from the table.
f) Delete the table NCOLLEGE.
6) Explain in detail the given subsets of MySQL;
a) DML b) DDL c) DTL

Q.5) Answer the following.(Any Two) (5M Each)


1) Write MySQL Commands for the following;
a) Create a database called SBI.
b) Create a table EMP, in database SBI.
Information Column Name Type
Employee Number ENO smallint (unsigned) Primary Key
Name NAME varchar(10)
Date Of Joining DOJ date
Age AGE smallint (Always Positive)
Salary SAL Decimal(10,2)

c) populate the above table with 4 rows using 2 INSERT statement each containing
information of 2 rows only.
12 SMIT 5th December, 2009 29 15,000.00
25 SUMIT 7th May, 2012 21 12,000.00
21 ARYAN 3rd December, 2010 22 25,000.00
48 PREM 12th December, 2015 25 14,500.00

d) Increase Salary of all employees by Rs. 2500.


e) Decrease salary by 10% if date of joining is after 1st April 2010.
f) Change size of NAME from 10 to 15.
g) Delete a column AGE.
h) Add a column POST with type varchar and size 20.
i) Make POST as Manager for all employees.
j) Change POST to OFFICER for name starts with S.

2) There exists a table called Employee, containing Employee Number (E_NO Smallint
Unsigned Primary Key), Employee Name (E_NAME Varchar(15)), AGE (E_AGE Smallint
Unsigned), Department (E_DEPT Varchar(8)), Date of joining (DOJ DATE), Salary (E_SAL
Decimal(8,2)). Write MySQL statements for the following;
a) Display all the records.
b) Display department, salary with heading SALARY and name for each employee.
c) Display all the details and HRA as 10% of salary fr all the records.
d) Remove Unsigned attribute from AGE column.
e) Display name, 25% of salary as 'BONUS PAID' and salary of employee no. 5 to employee
no. 12
f) Display a message '<E_NAME> is working for <E_DEPT> department, since <DOJ>' for
each record.
g) Display name, date of joining in the format of 'Thu 22-Feb-2012' and Salary round off to
nearest 10 fr each row.
h) Display records if age is in the range of 25 to 45.
i) Display name and department where 2nd character of department name is A.
j) Display records where first 2 characters of name are same as last 2 characters of name.

3) A table called as STUDENT contains roll number (ROLL), Name of the student (SNAME),
Date of birth (DOB) and marks in 4 subject (M1, M2, M3, M4). Write MySQL statement for the
following;
a) Display all details with total marks and average of marks for all the students.
b) Display name of the student and average of marks with the heading 'Avg Marks'.
c) Display records where marks in any subject are 30 or less.
d) Display records where total of marks is above 300 and name starting with letter D.
e) Display name of the student with prefix “Mr./Mrs.” and average of marks if average is
above 75.
f) Display records where name is not ending with letter H or A or S.
g) Display records where total f marks are not between 150 and 360.
h) Display records where student is born on Sunday or Tuesday.
i) Display records where length of student name is even.
j) Display first 3 character of student name, last 2 charecters of name, 5 th & 6th character of
name for each record.

:) Best of Luck :)

You might also like