0% found this document useful (0 votes)
13 views5 pages

Viva Questions Ip

Uploaded by

class 9b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Viva Questions Ip

Uploaded by

class 9b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Q1 what is primary key, candidate key, alternate key.

Ans:
a) Primary key: is a column in a table which is unique identity of every row. Only one primary key is allowed in a table.
Values in a primary key cannot be null and cannot be duplicate
example: admission number, adhar number

b) Candidate Key: All the columns which are eligible to become primary key are called candidate keys. There can be
more than one candidate keys in a table. Primary key is selected from candidate keys

c) Alternate key: All the candidate keys which could not become primary key are called alternate key

Q2. What are NULL values?


Ans: Null values means empty values. Zero is not a null value. Zero is a value

Q. What is DBMS and RDBMS?


Ans: DBMS is Database management system and RDBMS is Relational Database management System

Q. What is MYSQL?
Ans: MYSQL is DBMS software

Q. What is SQL?
Ans: SQL is called Structure Query Language. It is language used inside MYSQL software

Q. What is use of MYSQL software?


Ans: It is used to create a database, tables and manipulate them

Q. What is degree and cardinality of a table?


Ans: Degree is number of rows and cardinality is number of columns in a table

Q. What is a relation?
Ans: Relation is another name for a table.

Q. Name two categories of SQL functions


Ans: There are two categories of SQL functions
a) Single Row functions
b) Aggregate functions

Q. What is the difference between single row and aggregate functions?


Ans: Single row functions work on individual row of a table
Aggregate functions work on a group of values

Q. Name all the Aggregate functions:


Sum (), min(), max(), count(), avg()

Q. What is difference between count(*) and count() function? (IMP)


Ans: Count(*) gives the number of rows in the table
Count() function counts number of values of a column

Q. Name the SINGLE ROW functions:


Ans: There are three categories of single row functions:
a) Maths/Numeric:
1. Pow()
2. Mod()
3. Round()
b) Char/String/Text
1. LCASE()
2. UCASE()
3. LENGTH()
4. LTRIM()
5. RTRIM()
6. TRIM()
7. LEFT()
8. RIGHT()
9. INSTR()
10. SUBSTR()

Note: SUBSTR() is also called SUBSTRING() or MID()

c) Date and Time functions


i. NOW()
ii. DAY()
iii. DAYNAME()
iv. MONTH()
v. MONTHNAME()
vi. YEAR()
vii. DATE()

Questions on MATHS Functions


Q. What is the use of mod() and pow() and round functions?
Ans: mod() is used to calculate the remainder
for ex: mod(10,3) =1
pow() is used calculate ab
for ex: pow(6,2) =36
round() is used to round off the numbers to n decimal places
For ex: round(109.58, 1) = 109.6

Questions on CHAR/STRING functions

Q. What is the use of string function LENGTH() ?


Ans: LENGTH() is used to tell the number of characters in a string.
For ex: LENGTH(“hi my name is khan”) = 18
(all characters including spaces, dots are counted)

Q. What is the used LCASE() and UCASE() functions?


Ans: LCASE() is used to convert the string in to capital letters.
For ex: LCASE(“Python”)
= PYTHON
UCASE() is used to convert the string in to small letters.
For ex: UCASE(“PYTHON”)
= python
Q. What is the use of TRIM() function?
Ans: TRIM() function is used to remove spaces from both beginning and ending of string

Q. What is the use of RTRIM() function?


Ans: RTRIM() function is used to remove spaces only from ending of a string (right side)

Q. What is the use of LTRIM() function.


Ans: LTRIM() is used to remove spaces from beginning of a string(Left side)

Q. What is the use of INSTR() function?


Ans: This function is used to find the position of one string in another string.

Ex: INSTR(“THIS IS A PEN”, “IS”) = 3


The above function will find starting position of ‘IS’ in the string “THIS IS A PEN” which is 3

Q. What is the use of SUBSTRING function?


Ans: SUBSTRING() is also called MID()

It is used to extract a sub string from another given string

Example:

1. Extract 5 characters starting from 2nd position from string “ORANGE AND APPLE”
SUBSTR(“ORANGE AND APPLE”, 2, 5)= RANGE

2. Extract 2 characters starting from 3rd position from string “LEARNING MYSQL”
MID(“LEARNING MYSQL”, 3, 2) = AR

Q. What is the use of LEFT() and RIGHT() functions?


Ans: LEFT() gives ‘n’ characters from left side of string (beginning of string)
LEFT(“MEEAKSHI”, 3)
Ans: MEE
RIGHT () gives ‘n’ characters from right side of string (ending of string)
RIGHT(“MEEAKSHI”, 4)
Ans: KSHI

Questions on DATE functions


Q. which function is used to display current date and time?

Ans: NOW() function

Q. What is the use of DAY() function?

Ans: It gives the numeric day from YEAR-MONTH-DAY


Example:

DAY(“2019-09-12”) = 12

Q. What is the use of DAYNAME() function?

Ans: It gives us the NAME of the day from YEAR-MONTH-DAY

EXAMPLE:

DAYNAME(“2022-04-24”) = SUNDAY

Q. What is the use of MONTH() function?

Ans: It gives the numeric MONTH from YEAR-MONTH-DAY

Ex:

MONTH(2022-04-24) = 4

Q. What is the use of MONTHNAME() function?

Ans: It gives the NAME of the month from YEAR-MONTH-DAY

EX: MONTHNAME(“2022-04-24”) = APRIL

Q. What is the use of YEAR() function?

Ans: It gives us the year from date

Ex: YEAR(“2022-09-06”) = 2022

General Questions

Q1. What is the command to create a database?


Ans: CREATE DATABASE NAMEofDATABASE
EX:
CREATE DATABASE SCHOOL

Q. What is the difference between ALTER TABLE command and UPDATE command
Ans:

Q. What is the difference between DROP TABLE and DELETE command


Ans:
Q. What is the difference between CHAR and VARCHAR datatypes?
Ans:
CHAR(N) VARCHAR(N)
Char is fixed length datatype Varchar is variable length datatype
If char(10) is datatype, it means a string will take If varchar(10) is datatype, it means a string may
exactly 10 characters even string is smaller then 10 take less number of characters if string is smaller
characters than 10 characters in length.

Q. What is difference between WHERE & HAVING Clause in SQL?(imp)


Ans:
Where clause is used to apply condition on individual row
Having Clause is used to apply condition on GROUPS

Q. How do we apply condition on GROUPS in SQL?


Ans: Using HAVING CLAUSE

Q. What is the use of ORDER BY clause in SQL? (imp)


Ans: It is used to sort the data. Sorting means arranging in ascending or descending order

Q. How do we sort the data(arrange in ascending or descending in SQL)?


Ans: Using ORDER BY clause

Q. What is the difference between DDL and DML commands?


Ans:
DDL DML
Data Definition language Data manipulation language
It contains the following commands It contains the following commands

ALTER UPDATE
CREATE DATABASE INSERT INTO
CREATE TABLE SELECT
DROP TABLE DELETE
DROP DATABASE

Q. Example of DDL and DML commands?


Ans: See above

You might also like