InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How do you create view in MySQL? |
|
Answer» In MYSQL, the CREATE VIEW STATEMENT is used to create a new view inside the database. Here’s the basic syntax of the statement: CREATE VIEW productList AS SELECT QTY, price, totalprice AS value FROM PRODUCT; |
|
| 2. |
What is view in MySQL? |
|
Answer» The VIEW is basically a VIRTUAL table which is USED to view certain and preferable rows or columns of the table. In practice, users can add a number of SQL functions, JOIN and WHERE clause to view the PRESENT data of the table. |
|
| 3. |
What is the difference between timestamp and datetime in MySQL? |
|
Answer» Timestamp in MYSQL Timestamp in MySQL is used when users want to convert the value from the current time zone to UTC zone for the sake of storage or UTC time zone to the current time zone for retrieval. DATETIME in MySQLDateTime in MySQL is used to insert values ‘YYYY-mm-DD’ in the table where yyyy is the year, mm is the month and dd is the date. This keyword is used to retrieve or to DISPLAY DATETIME values in Mysql. |
|
| 4. |
How to convert a string to utf 8 in MySQL? |
|
Answer» Here’s a code script to convert string data to UTF 8 in your database: HEADER('Content-Type: text/plain; charset=utf-8'); |
|
| 5. |
What is the degree of a table in MySQL? |
|
Answer» The degree of a table is the number of COLUMNS in the given table. It is also CALLED as Arity. It is the range of ENTITIES inside each ENTITY type that can be linked via a given RELATIONSHIP type. |
|
| 6. |
How to upload a large file through phpmyadmin in MySQL? |
|
Answer» It is the best way to upload large CSV FILES through the LOAD DATA command. Syntax: LOAD DATA LOCAL INFILE "your file NAME" INTO TABLE table name FIELDS TERMINATED by ’,’ LINES TERMINATED BY ’\n’ |
|
| 7. |
What is temporary table in MySQL? |
|
Answer» In MySQL, a temporary table is a distinct type of table that approves you to save a transient end RESULT SET, in which you can REUSE countless INSTANCES in a single session. A brief table is created with the aid of the use of the CREATE TEMPORARY TABLE statement. |
|
| 8. |
What is heap table in MySQL? |
|
Answer» HEAP tables are in memory. No TEXT or BLOB FIELDS are ALLOWED inside HEAP tables. They are TYPICALLY USED for high-speed transient storage. |
|
| 9. |
How do I count the number of records in a MySQL query? |
| Answer» | |
| 11. |
What is constraints? Also explain the different types of constraints? |
|
Answer» These are the set of RULES applied to COLUMNS on the table. It is USED to bound the type of data that can go into a table. Types of constraints
|
|
| 12. |
What is the difference between having and where clause in Mysql? Explain |
|
Answer» WHERE term is USED for FILTERING ROWS, and it APPLIES to every row but HAVING term is used to filter groups. WHERE can be used without the GROUP BY but HAVING clause cannot be used without the GROUP BY. |
|
| 13. |
Write a query to fetch common records between two tables using MySQL? |
|
Answer» USING INTERSECT SELECT * FROM EmployeeSalary
|
|
| 14. |
Write a query to fetch duplicate records from a table using MySQL? |
|
Answer» SELECT EmpId, Project, Salary, COUNT(*) FROM EmployeeSalary GROUP BY EmpId, Project, Salary HAVING COUNT(*) > 1; |
|
| 15. |
How to display top 10 rows in Mysql? |
| Answer» | |
| 16. |
Write a query to display even rows in student table using MySQL? |
| Answer» | |
| 17. |
What are the stored procedures in MySQL? Also, write an example. |
|
Answer» The stored procedure is LIKE a subprogram in a typical COMPUTING language which is stored in the database. A stored procedure contains the name, list of parameters, and the SQL statements. All the RELATIONAL database system works as PILLARS for stored procedures. In this example, we are CREATING a simple procedure called job_data, when this procedure will get executed, all the data from "jobs" tables will get displayed. ExampleDELIMITER // CREATE PROCEDURE GetAllPages() DELIMITER ; |
|
| 18. |
How to display odd rows in Employee table in Mysql? |
|
Answer» SELECT id, name, department FROM EMPLOYEE where MOD(id,2) = 1 |
|
| 19. |
Write a query to find duplicate rows In table? |
|
Answer» SELECT std_id, COUNT(std_id) as cnt FROM STUDENT GROUP by std_id having cnt > 1 |
|
| 21. |
What is the difference between CHAR and VARCHAR in MySQL? |
Answer»
|
|
| 22. |
In Mysql, what is joins? Explain |
|
Answer» In Mysql, joins are used to RETRIEVE data from multiple TABLES. It is performed whenever two or more tables are joined. There are three types of MySQL joins:- |
|
| 23. |
What is difference between function and procedure in MySQL? |
||||||||||
Answer»
|
|||||||||||
| 24. |
How to retrieve the current version of a MySQL? |
|
Answer» You can use this query in your phpmyadmin SELECT version(); 44. What are aggregate functions in MySQL?The MySQL aggregate function performs a calculation on a SET of values, and it returns a single value as output. It IGNORES NULL values when it performs calculation except for the COUNT function. MySQL provides many aggregate functions that are listed below.
|
|
| 25. |
What is the difference between BETWEEN and IN operators in Mysql? |
|
Answer» Between operator is used to select a range of data between TWO values. It can be TEXTS, numbers, and DATES, etc. Syntax: Select * from TABLENAME where FIELDNAME between VALUE1 and VALUE2 IN operator is used to CHECK for a value in the given SET of values. Syntax: Select * from TABLENAME where FIELDNAME IN ('VALUE1','VALUE2',...) Related Article: What Is The Difference Between MySQL And MongoDB |
|
| 26. |
How to use GROUP_CONCAT with different SEPARATOR in MySQL? |
|
Answer» SELECT ID, GROUP_CONCAT(DEPARTMENT SEPARATOR ' ') AS department FROM EMPLOYEE GROUP by id; |
|
| 27. |
In Mysql, what is the default storage engine? |
| Answer» | |
| 28. |
How to change the database engine in MySQL? |
| Answer» | |
| 29. |
What are Storage Engines in Mysql? |
|
Answer» Storage ENGINES are Mysql components, that can handle the OPERATIONS for different table types to STORE and MANAGE information in a database.
|
|
| 30. |
What are the advantages of MySQL? |
| Answer» | |
| 31. |
Is Mysql is a programming language? |
|
Answer» It is a LANGUAGE but not a PROGRAMMING Language. It is a relational DATABASE MANAGEMENT SYSTEM. |
|
| 32. |
How to control the max size of a HEAP table? |
|
Answer» The maximum size of the HEAP table can be controlled by the MySQL CONFIG variable CALLED max_heap_table_size. |
|
| 33. |
What is federated tables in MySQL? |
|
Answer» It is a table that points to a table in ANOTHER MySQL DATABASE instance. It can be seen as a VIEW of this remote database. Other RDBMS have the same concepts for EXAMPLE database LINKS. |
|
| 34. |
What's new in MySQL 8? |
|
Answer» There are a number of unique FEATURES that are INCORPORATED in Mysql 8 include-
|
|
| 35. |
What is slow query log in MySQL? |
|
Answer» In general slow query, the log is BASICALLY used in Mysql for the determination of which DATABASE queries will take a long duration to run. Moreover, a slow query log in MySQL simplifies that operations in the context of efficient and time-consuming queries. In order to enable the slow query log the command- GET global slow_query_log – ‘ON’; is used Also Read: PostgreSQL interview QUESTIONS |
|
| 36. |
How to write an optimized query in MySQL? |
|
Answer» To write an optimized query in MySQL, below are some GUIDELINES:
|
|
| 37. |
How to save images in MySQL? |
|
Answer» Images in MySQL can be stored as blobs. For SAVING them: All the database images are converted into the blobs FIRST. Then, they will GET INSERTED into the database, and LATER on, it will get stored into the disk. |
|
| 38. |
Can a primary key be dropped in MySQL? If yes, how? |
|
Answer» Yes, the primary key can be DROPPED in MYSQL with the use of the “ALTER TABLE” statement. Syntax: ALTER TABLE table_name DROP PRIMARY KEY |
|
| 39. |
What are the differences between mysql_fetch_array () mysql_fetch_object () mysql_fetch_row ()? |
|||||||||
Answer»
|
||||||||||
| 40. |
What is the use of enum in MySQL? How it is different from set? |
||||
|
Answer» In MySQL, an ENUM is actually a string object whose value is selected from the list of permitted values pre-defined during the TIME of a column creation. It is USED because it provides compact data storage in ADDITION to readable queries and output. Here’s the DIFFERENCE between an ENUM and a SET
|
|||||
| 41. |
What are the difference between char_length and length in MySQL? |
||||
Answer»
|
|||||
| 42. |
How to make a copy values from one column to another in Mysql? |
| Answer» | |
| 43. |
What is regex in MySQL? |
|
Answer» Regex is an operational and powerful pattern that can help the users for the IMPLEMENTATION of a powerful search utility function for database systems. Moreover, it is an operator which is used when we require matching REGULAR expressions. In addition to this, it also supports a wider range of meta-characters which allow flexibility and more control over the database structure when performing pattern matching. ExampleMatch BEGINNING of string(^): SELECT name FROM users WHERE name REGEXP '^bestinterviewquestion'; |
|
| 44. |
How to store binary data in MySQL? |
|
Answer» Binary DATA can be stored in Mysql in different WAYS such as
|
|
| 45. |
What are the difference between MongoDB and MySQL? |
||||
Answer»
|
|||||
| 46. |
What is the difference between MyISAM dynamic and MyISAM static in MySQL? |
||||
Answer»
|
|||||
| 47. |
How would you select all the users whose phone is null MySQL? |
| Answer» | |
| 48. |
Why use triggers in MySQL? |
|
Answer» In MySQL, a trigger corresponds to a set of actions running AUTOMATICALLY when a PARTICULAR change OPERATION like SQL INSERT, UPDATE, or DELETE query is performed on a table. ExampleCREATE TRIGGER data_backup BEFORE UPDATE ON users |
|
| 49. |
What are the drivers in MySQL? |
|
Answer» In MySQL, standards-based DRIVERS for JDBC, ODBC, and .NET are provided in order to enable developers in building DATABASE applications with their LANGUAGE of choice. Available Drivers in MySQL:
JDBC, ODBC, and .Net drivers are necessary for MySQL as they enable the developers for building their database applications. |
|
| 50. |
What is the difference between IS NULL & IS NOT NULL? |
|
Answer» IS NULL checks to see if the cell is empty but IS NOT NULL checks to see if the cell is not empty. Example : SELECT id FROM USERS WHERE 'user_type' IS NOT NULL; SELECT id FROM users WHERE 'user_type' NOT IS NULL; NOTE: This is very ESSENTIAL MYSQL query interview questions. |
|