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. |
What are Roles in MySQL and briefly explain any three |
|
Answer» A MySQL role is a named collection of privileges. Like user accounts, roles can have privileges GRANTED to and revoked from them. A user account can be granted roles, which grants to the account the privileges associated with each role. This enables assignment of sets of privileges to accounts and PROVIDES a convenient alternative to granting individual privileges, both for conceptualizing desired privilege assignments and implementing them. CREATE ROLE and DROP ROLE ENABLE roles to be created and removed. CREATE ROLE ‘admin’, ‘devops’; DROP ROLE ‘admin’, ‘devops’;GRANT and REVOKE enable privilege assignment and revocation for user accounts and roles. GRANT ALL ON db1.* TO ‘admin’@’localhost’; REVOKE INSERT ON *.* FROM ‘admin’@’localhost’;SHOW GRANTS DISPLAYS privilege and role assignments for user accounts and roles. SHOW GRANTS FOR 'admin'@'localhost'; |
|
| 2. |
What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? |
Answer»
For INNER joins, the order doesn't matter. The queries will return the same results, as long as we change your selects from SELECT * to SELECT a.*, b.*, c.*. For (LEFT, RIGHT or FULL) OUTER joins, YES, the order matters. First, outer joins are not COMMUTATIVE, so a LEFT JOIN b is not the same as b LEFT JOIN a |
|
| 3. |
What are MySQL aliases |
|
Answer» MySQL supports two kinds of aliases which are known as column ALIAS and table alias. SOMETIMES the names of columns are so technical that make the query’s OUTPUT very DIFFICULT to understand. To give a column a descriptive name, you use a column alias. SELECT [column_1 | expression] AS descriptive_name FROM table_name;To give a column an alias, you use the AS keyword followed by the alias. If the alias contains space, you must quote it.You can use an alias to give a table a different name. You assign a table an alias by using the AS keyword as the following syntax table_name AS table_aliasThe alias for the table is called table alias. Like the column alias, the AS keyword is optional so you can omit it. |
|
| 4. |
Creating a table with query |
|
Answer» >CREATE TABLE myset (col SET('a', 'B', 'c', 'd')); And INSERTING the values >INSERT INTO myset (col) VALUES ('a,d'), ('d,a'), ('a,d,a'), ('a,d,d'), ('d,a,d');what will be the output of this query? >SELECT col FROM myset; | col | +------+ | a,d | | a,d | | a,d | | a,d | | a,d |For a value containing more than one SET element, it does not matter what ORDER the elements are listed in when you insert the value. It also does not matter how MANY times a given element is listed in the value. When the value is retrieved later, each element in the value appears once, with elements listed according to the order in which they were specified at table CREATION time. |
|
| 5. |
How to change the data type of requireDate field in query |
|
Answer» SELECT orderNumber, requiredDate FROM orders WHERE requiredDate BETWEEN '2018-01-01' AND '2018-01-31'; The query SELECTS orders WHOSE required dates are in January 2018. The data type of the requireDate COLUMN is DATE, therefore, MySQL has to convert the literal strings: '2018-01-01' and '2018-01-31'into TIMESTAMP values before EVALUATING the WHERE condition. SELECT orderNumber, requiredDate FROM orders WHERE requiredDate BETWEEN CAST('2018-01-01' AS DATETIME) AND CAST('2018-01-31' AS DATETIME); |
|
| 6. |
What is a routine and how is it created |
|
Answer» A stored ROUTINE is either a PROCEDURE or a function. Stored ROUTINES are created with the CREATE PROCEDURE and CREATE FUNCTION statements DELIMITER // CREATE PROCEDURE GetAllProducts() BEGIN SELECT * FROM PRODUCTS; END // DELIMITER ; |
|
| 7. |
What is datatype set |
|
Answer» A SET is a string object that can have zero or more values, each of which MUST be CHOSEN from a list of permitted values specified when the table is created. SET column values that CONSIST of multiple set members are specified with members separated by commas (,). A CONSEQUENCE of this is that SET member values should not themselves CONTAIN commas. |
|
| 8. |
What is character set in MySQL. What is the default character set in MySQL |
|
Answer» A character set is a set of symbols and encodings. A collation is a set of RULES for comparing characters in a character set MySQL is capable of doing these things
Latin1 is the default character set in MySQL |
|
| 9. |
What is a storage engine.How to prevent the use of a particular storage engine? |
|
Answer» A DATABASE engine (or storage engine) is the underlying software component that a database management system (DBMS) uses to create, read, UPDATE and delete (CRUD) data from a database. The disabled_storage_engines configuration OPTION defines which storage engines cannot be used to create tables or tablespaces. By default, disabled_storage_engines is empty (no engines disabled), but it can be SET to a comma-separated list of one or more engines. |
|
| 10. |
What is PDO and the reasons to prefer it over MySQLi |
|
Answer» PDO is PHP Data Objects. PDO will WORK on 12 different database SYSTEMS, whereas MySQLi will only work with MySQL databases. So, if you have to switch your project to use another database, PDO MAKES the process easy. You only have to change the CONNECTION string and a few queries. With MySQLi, you will need to rewrite the entire code - queries included. |
|
| 11. |
Explain create table statement and its difference with show create table |
|
Answer» CREATE TABLE [IF NOT EXISTS] table_name( column_list ) ENGINE=storage_engine CREATE TABLE `test`.`car` ( `id` INT(12) NULL AUTO_INCREMENT , `NAME` VARCHAR(20) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB; SHOW create table statement shows the CREATE TABLE statement that CREATES the named table. |
|
| 12. |
Different steps to import SQL file by using command line in MySQL? |
|
Answer» DIFFERENT steps to import SQL file by using command LINE in MySQL? Below are the different steps to import SQL file in MySQL command line:- (1)First we will open the MySQL command line. (2)Now type the path of our MySQL bin DIRECTORY and press "Enter". (3)Now we will paste the SQL file INSIDE the bin folder of MySQL server. (4)Now we will create a database in MySQL. (5)Now we will use the particular database where we want to import the SQL file. (6)Now type source databasefileofSQL.sql and press "Enter" (7)Now SQL file is upload successfully. |
|
| 13. |
Why we use IGNORE keyword query in MySQL? |
|
Answer» Why we use IGNORE keyword query in MySQL? |
|
| 14. |
What do you understand by i_am_a_dump flag in MySQL? |
|
Answer» What do you understand by i_am_a_dump flag in MySQL? |
|
| 15. |
What is the default port for MySQL? |
|
Answer» What is the DEFAULT PORT for MYSQL? |
|
| 16. |
How to enable slow query log MySQL? |
|
Answer» How to enable slow query log MySQL? |
|
| 17. |
What is BLOB and its types in MySQL? |
|
Answer» What is BLOB and its types in MYSQL? |
|
| 18. |
What are scrollable cursor and how it is different from standard cursor in MySQL? |
|
Answer» What are scrollable CURSOR and how it is DIFFERENT from standard cursor in MYSQL? |
|
| 19. |
What is Role of tee command in MySQL? |
|
Answer» What is ROLE of tee command in MySQL? |
|
| 20. |
Define Tee command in MySQL? |
|
Answer» DEFINE Tee COMMAND in MySQL? Tee is a Unix command which takes standard out output of unix command and it will writes to both termical and a file. And there is no MySQL client command that performed the same function. tee FOLLOWED by a FILENAME turns on MySQL logging to a specified file. It can be stopped by command note. Below is the syntax for creating Tee command:-
|
|
| 21. |
Default time to log a query in slow query log and can we change that in MySQL? |
|
Answer» Default time to log a query in slow query log and can we CHANGE that in MySQL? |
|
| 22. |
How do we stop Slow Query Log in MySQL? |
|
Answer» How do we stop Slow Query Log in MYSQL? |
|
| 23. |
What are the common MySQL functions |
|
Answer» What are the common MySQL functions |
|
| 24. |
How do we return 100 records from table starts from 25th record in MySQL? |
|
Answer» How do we RETURN 100 records from table starts from 25th record in MySQL? |
|
| 25. |
Different tables present in MySQL |
|
Answer» Below are the FIVE TYPES of table in MySQL |
|
| 26. |
Who was started and owned MySQL? |
|
Answer» Who was started and owned MySQL? |
|
| 27. |
What is heap table and other name of these table in MySQL? |
|
Answer» What is heap table and other NAME of these table in MYSQL? |
|
| 28. |
How to view all databases available on to the MySQL Server? |
|
Answer» How to view all DATABASES available on to the MySQL SERVER? |
|
| 29. |
Way to clear screen in MySQL in Window operating system? |
|
Answer» Way to clear screen in MySQL in Window OPERATING system? |
|
| 30. |
What are different tables and default database present in MySQL? |
|
Answer» What are different tables and DEFAULT database PRESENT in MySQL? |
|
| 31. |
Difference between char_length and Length in MySQL? |
|
Answer» Difference between char_length and Length in MySQL? |
|
| 32. |
Can we use "Order BY" in delete statement in MySQL Query? |
|
Answer» Can we USE "ORDER BY" in delete STATEMENT in MySQL Query? |
|