You are on page 1of 4

THEORY QUESTIONS :

1.write difference between Mysql and Sql


Answer:
1.MySQL is the popular open-source database available in the market,
which is developed by the Swedish company MySQL AB. Where as SQL
is a programming language that is useful for managing our relational
databases.
2. MySQL is used for data handling storing ,deleting and updating the
data in tabular form. Where as SQL is used to query and operate the
database .
3.MySQL is used as RDBMS for managing relational database .where as
SQL commands are used in various DBMS and RDBMS .MySQL is itself
uses SQL commands.

2.What is RDBMS .
Answer:-
1.RDBMS stands for Relational Database Management System.
2.RDBMS is a program used to maintain a relational database.
3.RDBMS is the basis for all modern database systems such as MySQL,
Microsoft SQL Server, Oracle, and Microsoft Access.
4.RDBMS used SQL queries to access the data in the database.

3.what is DDL.
Answer:-
1.DDL is an abbreviation of Data Definition Language.
2.The DDL Commands in Structured Query Language are used to create
and modify the schema of the database and its objects.
3.The syntax of DDL commands is predefined for describing the data.
4.The commands of Data Definition Language deal with how the data
should exist in the database.
5.There are basically five commands in SQL
1. CREATE Command
2. DROP Command
3. ALTER Command
4.TRUNCATE Command
5.RENAME Command
4. what is DML
Answer:
1.DML is an abbreviation of Data Manipulation Language.
2.The DML commands in Structured Query Language change the data
present in the SQL database.
3. We can easily access, store, modify, update and delete the existing
records from the database using DML commands.
4.there are basically four commands in SQL
1. SELECT Command
2. INSERT Command
3. UPDATE Command
4. DELETE Command

5.What is DQL
Answer
1.DQL is an abbreviation of Data Query Language .
2.DQL statements are used for performing queries on the data within
schema objects.
3.The purpose of the DQL Command is to get some schema relation
based on the query passed to it.
4. We can define DQL as follows it is a component of SQL statement
that allows getting data from the database and imposing order upon it.
5 .It includes the SELECT statement.
6.This command allows getting the data out of the database to perform
operations with it.

6.Write a difference between primary and foreign key.


Answer:-
1.primay key is used to uniquely identify data in the table. And foreign
key is used to maintain relationship between tables
2.primary key can’t be null .where as foreign key accept the null value
3. Two or more rows can’t have same primary key where as It can carry
duplicate value for a foreign key attribute
4. Primary key constraint can be defined on temporary table where as It
can’t be defined on temporary tables .
PRACTICAL QUESTIONS :
1 .Write a query to fetch duplicates record from employee table
Answer:
SELECT ID ,COUNT(ID)
FROM employee
GROUP BY ID
HAVING COUNT(ID)>1

2.Create a copy of the employee table and keep only female employees
Answer:
SELECT *FROM employee TO emp_1
WHERE Gender = ‘Female’;

3. Write a query to find the third highest salary from the employee table
Answer:
SELECT *FROM employee
ORDER BY decs LIMIT 3
4.write a query to display first and last record from employee table ID
Answer:-
SELECT * FROM employee
ORDER BY ID asc LIMIT 1
UNION
SELECT *FROM employee
ORDER BY ID decs LIMIT 1
5. Write a query to get last three records from employee table
Answer :-
SELECT *FROM employee
ORDER BY ID decs LIMIT 3
ORDER BY ID asc;
6.Select all the even number of records from table.
Answer:-
SELECT *FROM employee
ORDER BY emp_no
Where Mod(rn,2);

7.write an sql query to get first character of fname from employee


Answer:
SELECT *Substring(Fname ,1,3) FROM employee
8. Write a query to get fname removing spaces from right
Answer:-
SELECT Trim(Fname) FROM employee ;

You might also like