Mysql Questions Answers






Default storage engine in Mysql 5 and Mysql 4 are____ and ____ respectively?

1 :MyISAM, InnoDB
2 :InnoDB, MyISAM
3 :MysqlEng5, MyISAM
4 :InnoDB, MysqlEng5
Answer : 2

Mysql is ______? (choose most suitable one)

1 :DBMS
2 :RDBMS
3 :File Management system
4 :Web Application
Answer : 2

Choose the correct one?

1 :SQL stands for Structured Query Language and it the langugae of RDBMS.
2 :SQL stands for Structured Quiz Language and it the langugae of DBMS.
3 :SQL stands for Structured Query Learning and it the langugae of RDBMS.
4 :None of the above
Answer : 1

Which statement is true?

1 :A Primary key implements referential integrity.
2 :A Primary key may contain NULL and duplicates values.
3 :A Primary key should not contain NULL and duplicates values.
4 :A Primary key is not mandatory in a table.
Answer : 3

A foreign key is used to join tables based on ____?

1 :Candidate key
2 :Unique key
3 :Primary key
4 :Alternate key
Answer : 3

A primary key implements ___ integrity whereas foreign key implements___integrity?

1 :Referential, Entity
2 :Entity, Referential
3 :Unique, Entity
4 :Entity, Unique
Answer : 2

DML stands for ___ whereas DDL stands for ____?

1 :Data Merge Language, Data Definition Language
2 :Data Manipulation Language, Data Dynamic Language
3 :Data Manipulation Language, Data Definition Language
4 :Data Manipulation Language, Dynamic Data Language
Answer : 3

INSERT, UPDATE, DELETE and SELECT statements are ___?

1 :DDL
2 :DCL
3 :DML
4 :DDM
Answer : 3

Command to delete the table named "test" is ____?

1 :DROP TABLE test;
2 :DEL TABLE test;
3 :DELETE TABLE test;
4 :TRUNC test;
Answer : 1

DELETE and TRUNCATE statements deletes the rows from a table. Following which statements are true?

1 :DELETE can use WHERE clause while TRUNCATE can not.
2 :Rows deleted using DETELE can be rolled back, but in case of TRUNCATE rollback is not possible.
3 :Both (a) and (b)
4 :None of the above
Answer : 3

A Composite key is?

1 :A type of foreign key, not commonly used.
2 :Same as candidate key.
3 :Composed of more than one columns.
4 :None of the above.
Answer : 3

Clause used to restrict rows returned by the query is_____?

1 :HAVING
2 :GROUP BY
3 :ORDER BY
4 :WHERE
Answer : 4

The keyword used to remove the duplicate rows from the result set in a SELECT statement?

1 :UNIQUE
2 :DIFFERENT
3 :DISTINCT
4 :None of the above.
Answer : 3

Database Normalization is the process of?

1 :Organising the database by decomposing tables to eliminate redundancy.
2 :Joining one or more tables to organize the database.
3 :Increasing the data redundancy in a database.
4 :None of the above
Answer : 1

A table to be in First Normal Form, must have a _______?

1 :Unique key
2 :Foreign key
3 :Primary key
4 :Alternate key
Answer : 3

If a table contains primary key which is a composite key. To be in 2nd Normal Form, all non-key column must depend on ?

1 :Whole primary key
2 :Part of primary key
3 :Both (a) and (b)
4 :None of the above
Answer : 1

The function used to return total number of records is____?

1 :TOTAL(*)
2 :COUNT(*)
3 :AGGRG(*)
4 :None of the above
Answer : 2

How to query the records form a table named "city" and sort by column named "pin" in descending order?

1 :SELECT * FROM city ORDER BY pin descending;
2 :SELECT * FROM city SORTBY pin desc;
3 :SELECT * FROM city ORDER BY pin desc;
4 :None of the above
Answer : 3

How to insert a record in a table named "city" having columns named "city_name", and "pin" with value "Bangalore" and "560001".

1 :INSERT INTO city("city_name", "pin") VALUES ("Bangalore", "560001");
2 :INSERT INTO city(city_name, pin) VALUES ("Bangalore", "560001");
3 :INSERT VALUES ("Bangalore", "560001") INTO city(city_name, pin);
4 :None of the above
Answer : 2

How to update a record in a table named "city" having columns (city_name, state) with new value (Bangalore, Karanataka) where pin is 560001

1 :UPDATE city SET city_name="Bangalore", state="Karnataka" WHERE pin="560001";
2 :UPDATE city WHERE city_name="Bangalore", state="Karnataka" AND pin="560001";
3 :MODIFY city SET city_name="Bangalore", state="Karnataka" WHERE pin="560001";
4 :CHANGE city SET city_name="Bangalore", state="Karnataka" WHERE pin="560001";
Answer : 1

In a table named "Dept" with column "salary", query all the records where salary is between 5000 to 10000 ?

1 :SELECT * FROM Dept WHERE salary > 5000 AND 10000;
2 :SELECT * FROM Dept WHERE salary IS BETWEEEN 5000 AND 10000;
3 :SELECT * FROM Dept WHERE salary RANGE 5000 AND 10000;
4 :SELECT * FROM Dept WHERE salary BETWEEN 5000 AND 10000;
Answer : 4

In a table named "Dept" with column "salary", query all the records where salary is 4000 and 5000 ?

1 :SELECT * FROM Dept WHERE salary LIKE(4000, 5000);
2 :SELECT * FROM Dept WHERE salary IS(4000, 5000);
3 :SELECT * FROM Dept WHERE salary IN(4000, 5000);
4 :SELECT * FROM Dept WHERE salary EXIST(4000, 5000);
Answer : 3

In a table named "Dept" with column "salary", query all the records where salary is not 6000 and 8000 ?

1 :SELECT * FROM Dept WHERE salary NOT IN(6000, 8000);
2 :SELECT * FROM Dept WHERE salary IS NOT(6000, 8000);
3 :SELECT * FROM Dept WHERE salary NOT EQUAL(6000, 8000);
4 :SELECT * FROM Dept WHERE salary NOT EXIST(6000, 8000);
Answer : 1

In a table named "Dept" with column "salary", select average salary?

1 :SELECT AVERAGE(salary) FROM Dept;
2 :SELECT salary/count(salary) FROM Dept;
3 :SELECT AVG(salary) FROM Dept;
4 :None of these
Answer : 3

In a table named "Dept" with column "salary", delete the record where salary is greater than "10000";

1 :DELETE FROM Dept WHERE salary IS GREATER 10000;
2 :DELETE FROM Dept WHERE salary <> 10000;
3 :DELETE FROM Dept WHERE salary > 10000;
4 :DELETE FROM Dept WHERE salary EXCEEDS 10000;
Answer : 3

1440052590mysql3.PNG

1 :a
2 :b
3 :c
4 :d
Answer : 1

INNER JOIN returns ?

1 :Only the matching records from two or more tables.
2 :Only unmatched records from two or more tables.
3 :All records from two or more tables.
4 :None of the above
Answer : 1

Choose the correct statement about LEFT JOIN ?

1 :Does not return any row from first table but only from second table.
2 :Does not return any row from second table but only from first table.
3 :Returns all records from first table and matching record from second table.
4 :None of the above
Answer : 3

Choose the correct statement about RIGHT JOIN ?

1 :Does not return any row from first table but only from second table.
2 :Returns all records from second table and matching record from first table.
3 :Does not return any row from second table but only from first table.
4 :None of the above
Answer : 2

In a table named "emp" having column "salary", select only record for the second heighest salary ?

1 :SELECT * FROM emp WHERE MAX(salary) LIMIT 1,2;
2 :SELECT TOP(salary) FROM emp LIMIT 2;
3 :SELECT * FROM emp ORDER BY salary DESC LIMIT 1, 1;
4 :None of the above
Answer : 3

First table "emp" with column as("id", "name", "email", "salary", "dept_id"). Second table named "dept" with columns ("id", "dept_name"). Choose correct inner join query ?

1 :SELECT e.name, e.email, e.salary, d.dept_name FROM emp e INNER JOIN dept d ON e.dept_id=d.id;
2 :SELECT emp.name, emp.salary, dept.dept_name FROM emp e WHERE e.id=d.id;
3 :Both (a) and (b)
4 :None of the above
Answer : 3

TO delete one column "email" from a table named "emp" ?

1 :MODIFY TABLE emp DELETE email;
2 :ALTER TABLE emp DELETE COLUMN email;
3 :ALTER TABLE emp DROP COLUMN email;
4 :None of the above
Answer : 3

A View is a _______? (Choose correct one)

1 :Virtual table
2 :Real table
3 :A type of query
4 :Not an object
Answer : 1

In a table named "emp" having column "salary", select heighest salary ?

1 :SELECT TOP(salary) FROM emp;
2 :SELECT MAXIMUM(salary) FROM emp;
3 :SELECT HEIGHEST(salary) FROM emp;
4 :SELECT MAX(salary) FROM emp;
Answer : 4

In a table named "emp", select record from 5 to 10 (inclusive) ?

1 :SELECT * FROM emp LIMIT 6 OFFSET 4;
2 :SELECT * FROM emp LIMIT 4, 6;
3 :SELECT * FROM emp LIMIT 5, 10;
4 :Both (a) and (b)
Answer : 4

All types of Normalization are ? (Choose most suitable answer)

1 :1NF, 2NF, 3NF, 4NF, 5NF, BCNF
2 :1NF, 2NF, 3NF
3 :1NF, 2NF, 3NF, BCNF
4 :1NF and 2NF
Answer : 1

SQL Constraints are rules for a table. Different types of SQL constraints are ?

1 :CANDIDATE KEY, FOREIGN KEY, UNIQUE, CHECK, DEFAULT and NOT NULL
2 :PRIMARY KEY, COMPOSITE KEY, UNIQUE, CHECK, DEFAULT and NOT NULL
3 :PRIMARY KEY, ALTERNATE KEY, UNIQUE, CHECK, DEFAULT and NOT NULL
4 :PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, DEFAULT and NOT NULL
Answer : 4

Command to see the columns and datatypes of a table is ?

1 :describe tablename;
2 :show tablename;
3 :fetch tablename;
4 :None of the above;
Answer : 1

Command to select the database named "Libray" and list all the table it contains are ?

1 :use Library; show tables;
2 :select database Library; List tables;
3 :use database Library; show tables;
4 :None of the above
Answer : 3

CHAR datatype in Mysql can hold minimum ____ to maximum ____ characters ?

1 :5, 200
2 :1, 200
3 :1, 245
4 :1, 255
Answer : 4

How to list all databases in Mysql ?

1 :list databases;
2 :show databases;
3 :list all databases;
4 :None of the above
Answer : 2

Difference between function NOW() and CURRENT_DATE() is ?

1 :NOW() returns current date as well as time, while CURRENT_DATE() returns current date only.
2 :Both return the current date.
3 :CURRENT_DATE() returns current date and time, while NOW() returns current date only.
4 :None of the above
Answer : 1

Query to display first 20 records is from table named "emp" is ?

1 :SELECT * FROM emp LIMIT 1, 50
2 :SELECT * FROM emp LIMIT 50
3 :SELECT * FROM emp LIMIT 0, 50;
4 :Both (b) and (c)
Answer : 4

In a table named "emp" with a column "email", select all records with NULL values ?

1 :SELCET * FROM emp WHERE email=NULL;
2 :SELECT * FROM emp WHERE email="NULL";
3 :SELECT * FROM emp WHERE email IS NULL;
4 :None of the above
Answer : 3

In a table named "emp" with a column "email", select all records with not NULL values ?

1 :SELECT * FROM emp WHERE email IS NOT NULL;
2 :SELCET * FROM emp WHERE email <> NULL;
3 :SELECT * FROM emp WHERE email !=NULL
4 :None of the above
Answer : 1










Best Interview Question Quiz Online Questions Answers