0% found this document useful (0 votes)
1 views3 pages

MySQL Interview Questions

The document provides a comprehensive overview of basic MySQL interview questions and answers, covering topics such as definitions, data types, service management, database and table operations, and SQL commands. Key differences between SQL and MySQL, as well as between various SQL operations like DROP, DELETE, and TRUNCATE, are also explained. Additionally, it discusses the use of JOINs and filtering with WHERE and HAVING clauses.

Uploaded by

norwin294
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)
1 views3 pages

MySQL Interview Questions

The document provides a comprehensive overview of basic MySQL interview questions and answers, covering topics such as definitions, data types, service management, database and table operations, and SQL commands. Key differences between SQL and MySQL, as well as between various SQL operations like DROP, DELETE, and TRUNCATE, are also explained. Additionally, it discusses the use of JOINs and filtering with WHERE and HAVING clauses.

Uploaded by

norwin294
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/ 3

Basic MySQL Interview Questions and Answers

Q: What is MySQL?

A: MySQL is an open-source relational database management system (RDBMS) that uses

Structured Query Language (SQL) for managing and manipulating databases.

Q: What are the differences between MySQL and SQL?

A: SQL is a language used to query and manage databases. MySQL is a software (RDBMS) that

uses SQL to perform database operations.

Q: What are the different data types in MySQL?

A: Numeric: INT, FLOAT, DOUBLE, DECIMAL

String: VARCHAR, CHAR, TEXT

Date/Time: DATE, DATETIME, TIME, TIMESTAMP

Boolean: TINYINT(1)

Q: What is the default port number for MySQL?

A: The default port is 3306.

Q: How do you start and stop the MySQL service?

A: Start: sudo service mysql start

Stop: sudo service mysql stop

Q: How do you create a database in MySQL?

A: CREATE DATABASE database_name;

Q: How do you create a table?

A: CREATE TABLE users (

id INT PRIMARY KEY AUTO_INCREMENT,

name VARCHAR(50),

email VARCHAR(100)
);

Q: How can you view all databases and tables in MySQL?

A: SHOW DATABASES;

USE database_name;

SHOW TABLES;

Q: How do you delete a database or a table?

A: DROP DATABASE database_name;

DROP TABLE table_name;

Q: What is the difference between DROP, DELETE, and TRUNCATE?

A: DROP removes the table or database completely.

DELETE removes specific rows from a table.

TRUNCATE removes all rows from a table quickly without logging individual row deletions.

Q: How do you insert data into a table?

A: INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com');

Q: How do you update data in a table?

A: UPDATE users SET email = 'john.doe@example.com' WHERE id = 1;

Q: How do you delete specific records?

A: DELETE FROM users WHERE id = 1;

Q: How do you fetch data using SELECT statements?

A: SELECT * FROM users;

SELECT name, email FROM users WHERE id = 1;

Q: What is the use of WHERE clause?

A: The WHERE clause filters records that meet specific conditions.

Example: SELECT * FROM users WHERE name = 'John';

Q: What is the difference between WHERE and HAVING?


A: WHERE is used before aggregation (e.g., GROUP BY)

HAVING is used after aggregation to filter grouped results.

Q: How do you sort results using ORDER BY?

A: SELECT * FROM users ORDER BY name ASC;

Q: What is LIMIT used for?

A: It limits the number of records returned: SELECT * FROM users LIMIT 5;

Q: What are wildcards in SQL and how do you use them?

A: Wildcards are used with LIKE for pattern matching.

% matches any number of characters.

_ matches a single character.

Example: SELECT * FROM users WHERE name LIKE 'J%';

Q: What is a JOIN? Name the types of joins.

A: A JOIN combines rows from two or more tables based on a related column.

Types: INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN (emulated in MySQL)

Q: What is the difference between INNER JOIN and LEFT JOIN?

A: INNER JOIN returns records with matching values in both tables.

LEFT JOIN returns all records from the left table and matched records from the right table.

You might also like