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.
| 51. |
How Do You Control The Max Size Of A Heap Table? |
|
Answer» MYSQL CONFIG VARIABLE max_heap_table_size. MySQL config variable max_heap_table_size. |
|
| 52. |
What Are Heap Tables In Mysql? |
|
Answer» HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or |
|
| 53. |
Explain Advantages Of Myisam Over Innodb? |
|
Answer» Much more conservative approach to disk space management - each MyISAM table is stored in a SEPARATE file, which could be compressed then with myisamchk if needed. With INNODB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 BYTES at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s EXECUTE slower than in MyISAM DUE to tablespace complexity. Much more conservative approach to disk space management - each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity. |
|
| 54. |
Explain Advantages Of Innodb Over Myisam? |
|
Answer» Row-level LOCKING, transactions, foreign KEY constraints and CRASH recovery. Row-level locking, transactions, foreign key constraints and crash recovery. |
|
| 55. |
What Does Myisamchk Do? |
|
Answer» It COMPRESSED the MYISAM TABLES, which reduces their disk USAGE. It compressed the MyISAM tables, which reduces their disk usage. |
|
| 56. |
Explain The Difference Between Myisam Static And Myisam Dynamic. ? |
|
Answer» In MyISAM STATIC all the fields have fixed width. The Dynamic MyISAM table WOULD include fields such as TEXT, BLOB, ETC. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you MIGHT lose some data, you know exactly where to look for the beginning of the next record. In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record. |
|
| 57. |
What Are Some Good Ideas Regarding User Security In Mysql? |
|
Answer» There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the NETWORK or the INTERNET). There are as few users as POSSIBLE (in the ideal CASE only root) who have unrestricted access. There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet). There are as few users as possible (in the ideal case only root) who have unrestricted access. |
|
| 58. |
Have You Ever Used Mysql Administrator And Mysql Query Browser? |
|
Answer» DESCRIBE the TASKS you ACCOMPLISHED with these TOOLS. Describe the tasks you accomplished with these tools. |
|
| 59. |
Use Mysqldump To Create A Copy Of The Database? |
|
Answer» <P>MYSQLDUMP -h mysqlhost -u USERNAME -p mydatabasename > dbdump.sql mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql |
|
| 60. |
How Do You Change A Password For An Existing User Via Mysqladmin? |
|
Answer» <P>MYSQLADMIN -U ROOT -p PASSWORD "newpassword" mysqladmin -u root -p password "newpassword" |
|
| 61. |
Can You Save Your Connection Settings To A Conf File? |
|
Answer» Yes, and name it ~/.my.conf. You might WANT to change the PERMISSIONS on the FILE to 600, so that it’s not READABLE by others. Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, so that it’s not readable by others. |
|
| 62. |
What Does Tee Command Do In Mysql? |
|
Answer» TEE FOLLOWED by a filename TURNS on MySQL logging to a specified file. It can be stopped by COMMAND note. tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command note. |
|
| 63. |
What's The Default Port For Mysql Server? |
|
Answer» 3306 is the DEFAULT PORT for MYSQL. 3306 is the default port for MYSQL. |
|
| 64. |
Explain The Difference Between Mysql And Mysql Interfaces In Php? |
|
Answer» MYSQL is the object-oriented VERSION of mysql LIBRARY FUNCTIONS. mysql is the object-oriented version of mysql library functions. |
|
| 65. |
How Do You Start Mysql On Linux? |
|
Answer» /etc/init.d/mysql START /etc/init.d/mysql start |
|
| 66. |
How Do You Start And Stop Mysql On Windows? |
|
Answer» NET START MYSQL, net STOP MySQL net start MySQL, net stop MySQL |
|
| 67. |
How Are Enums And Sets Represented Internally? |
|
Answer» As UNIQUE INTEGERS REPRESENTING the POWERS of two, due to storage optimizations. As unique integers representing the powers of two, due to storage optimizations. |
|
| 68. |
What Are Enums Used For In Mysql? |
|
Answer» You can limit the possible values that go into the table. CREATE TABLE MONTHS (month ENUM ‘January’, ‘FEBRUARY’, ‘March’,…); INSERT months VALUES (’APRIL’); You can limit the possible values that go into the table. CREATE TABLE months (month ENUM ‘January’, ‘February’, ‘March’,…); INSERT months VALUES (’April’); |
|
| 69. |
How Do You Convert Between Unix Timestamps And Mysql Timestamps? |
|
Answer» UNIX_TIMESTAMP CONVERTS from MYSQL TIMESTAMP to UNIX timestamp, FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp. UNIX_TIMESTAMP converts from MySQL timestamp to Unix timestamp, FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp. |
|
| 70. |
What's The Difference Between Unix Timestamps And Mysql Timestamps? |
|
Answer» INTERNALLY Unix TIMESTAMPS are stored as 32-bit integers, while MySQL timestamps are stored in a similar manner, but REPRESENTED in readable YYYY-MM-DD HH:MM:SS format. Internally Unix timestamps are stored as 32-bit integers, while MySQL timestamps are stored in a similar manner, but represented in readable YYYY-MM-DD HH:MM:SS format. |
|
| 71. |
How Do You Add Three Minutes To A Date? |
|
Answer» ADDDATE(techpreparation_publication_date, INTERVAL 3 MINUTE) ADDDATE(techpreparation_publication_date, INTERVAL 3 MINUTE) |
|
| 72. |
How Do You Offload The Time/date Handling To Mysql? |
|
Answer» SELECT DATE_FORMAT(techpreparation_timestamp, ‘%Y-%m-%d’) from techpreparation_questions; A SIMILAR TIME_FORMAT FUNCTION DEALS with TIME. SELECT DATE_FORMAT(techpreparation_timestamp, ‘%Y-%m-%d’) from techpreparation_questions; A similar TIME_FORMAT function deals with time. |
|
| 73. |
How Do You Get The Month From A Timestamp? |
|
Answer» SELECT MONTH(techpreparation_timestamp) from techpreparation_questions; SELECT MONTH(techpreparation_timestamp) from techpreparation_questions; |
|
| 74. |
What Does + Mean In Regexp? |
|
Answer» At least one character. APPENDIX G. Regular EXPRESSIONS from MYSQL manual is WORTH perusing before the interview. At least one character. Appendix G. Regular Expressions from MySQL manual is worth perusing before the interview. |
|
| 75. |
What Do % And _ Mean Inside Like Statement? |
|
Answer» % CORRESPONDS to 0 or more characters, _ is EXACTLY one character. % corresponds to 0 or more characters, _ is exactly one character. |
|
| 76. |
How Do You Convert A String To Utf-8? |
|
Answer» SELECT (techpreparation_question USING UTF8); SELECT (techpreparation_question USING utf8); |
|
| 77. |
What's The Difference Between Char_length And Length? |
|
Answer» The first is, NATURALLY, the character COUNT. The second is byte count. For the LATIN characters the numbers are the same, but they’re not the same for Unicode and other encodings. The first is, naturally, the character count. The second is byte count. For the Latin characters the numbers are the same, but they’re not the same for Unicode and other encodings. |
|
| 78. |
How Do You Get A Portion Of A String? |
|
Answer» SELECT SUBSTR(TITLE, 1, 10) from techpreparation_questions; SELECT SUBSTR(title, 1, 10) from techpreparation_questions; |
|
| 79. |
How Do You Concatenate Strings In Mysql? |
|
Answer» CONCAT (STRING1, STRING2, string3) CONCAT (string1, string2, string3) |
|
| 80. |
How Do I Find Out All Databases Starting With 'tech' To Which I Have Access To? |
|
Answer» SHOW DATABASES LIKE ‘tech%’; |
|
| 81. |
When You Create A Table, And Then Run Show Create Table On It, You Occasionally Get Different Results Than What You Typed In. What Does Mysql Modify In Your Newly Created Tables? |
|
Answer» 1. VARCHARs with LENGTH less than 4 BECOME CHARs 1. VARCHARs with length less than 4 become CHARs |
|
| 82. |
How Would You Change A Table To Innodb? |
|
Answer» ALTER TABLE techpreparation_questions ENGINE INNODB; ALTER TABLE techpreparation_questions ENGINE innodb; |
|
| 83. |
How Would You Delete A Column? |
|
Answer» ALTER TABLE techpreparation_answers DROP answer_user_id. ALTER TABLE techpreparation_answers DROP answer_user_id. |
|
| 84. |
How Would You Change A Column From Varchar(10) To Varchar(50)? |
|
Answer» ALTER TABLE techpreparation_questions CHANGE techpreparation_content techpreparation_CONTENT VARCHAR(50). ALTER TABLE techpreparation_questions CHANGE techpreparation_content techpreparation_CONTENT VARCHAR(50). |
|
| 85. |
How Can You See All Indexes Defined For A Table? |
|
Answer» SHOW INDEX FROM techpreparation_questions; SHOW INDEX FROM techpreparation_questions; |
|
| 86. |
When Would You Use Order By In Delete Statement? |
|
Answer» When you’re not deleting by row ID. Such as in DELETE FROM techpreparation_com_questions ORDER BY timestamp LIMIT 1. When you’re not deleting by row ID. Such as in DELETE FROM techpreparation_com_questions ORDER BY timestamp LIMIT 1. |
|
| 87. |
On Executing The Delete Statement I Keep Getting The Error About Foreign Key Constraint Failing. What Do I Do? |
|
Answer» What it means is that so of the DATA that you’re trying to DELETE is still alive in another table. Like if you have a table for universities and a table for students, which contains the ID of the university they go to, running a delete on a university table will fail if the students table still contains people enrolled at that university. Proper way to do it would be to delete the offending data FIRST, and then delete the university in question. Quick way would involve running SET foreign_key_checks=0 before the DELETE command, and setting the parameter back to 1 after the DELETE is done. If your foreign key was FORMULATED with ON DELETE CASCADE, the data in dependent tables will be removed automatically. What it means is that so of the data that you’re trying to delete is still alive in another table. Like if you have a table for universities and a table for students, which contains the ID of the university they go to, running a delete on a university table will fail if the students table still contains people enrolled at that university. Proper way to do it would be to delete the offending data first, and then delete the university in question. Quick way would involve running SET foreign_key_checks=0 before the DELETE command, and setting the parameter back to 1 after the DELETE is done. If your foreign key was formulated with ON DELETE CASCADE, the data in dependent tables will be removed automatically. |
|
| 88. |
What Does -i-am-a-dummy Flag To Do When Starting Mysql? |
|
Answer» MAKES the MYSQL engine REFUSE UPDATE and DELETE commands where the WHERE clause is not present. Makes the MySQL engine refuse UPDATE and DELETE commands where the WHERE clause is not present. |
|
| 89. |
How Do You Find Out Which Auto Increment Was Assigned On The Last Insert? |
|
Answer» SELECT LAST_INSERT_ID() will RETURN the last value ASSIGNED by the auto_increment function. NOTE that you don’t have to SPECIFY the table NAME. SELECT LAST_INSERT_ID() will return the last value assigned by the auto_increment function. Note that you don’t have to specify the table name. |
|
| 90. |
What Does This Query Mean: Select User_name, User_isp From Users Left Join Isps Using (user_id) ? |
|
Answer» It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id |
|
| 91. |
How Would You Select All The Users, Whose Phone Number Is Null? |
|
Answer» SELECT user_name FROM USERS WHERE ISNULL(user_phonenumber); SELECT user_name FROM users WHERE ISNULL(user_phonenumber); |
|
| 92. |
How Would You Write A Query To Select All Teams That Won Either 2, 4, 6 Or 8 Games? |
|
Answer» SELECT team_name FROM TEAMS WHERE team_won IN (2, 4, 6, 8) SELECT team_name FROM teams WHERE team_won IN (2, 4, 6, 8) |
|
| 93. |
You Wrote A Search Engine That Should Retrieve 10 Results At A Time, But At The Same Time You'd Like To Know How Many Rows There're Total. How Do You Display That To The User? |
|
Answer» SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS(); The SECOND query (not that COUNT() is never used) will TELL you how many RESULTS there’re total, so you can display a PHRASE "Found 13,450,600 results, displaying 1-10". Note that FOUND_ROWS does not pay attention to the LIMITS you specified and always returns the total number of rows affected by query. SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS(); The second query (not that COUNT() is never used) will tell you how many results there’re total, so you can display a phrase "Found 13,450,600 results, displaying 1-10". Note that FOUND_ROWS does not pay attention to the LIMITs you specified and always returns the total number of rows affected by query. |
|
| 94. |
How Do You Return The A Hundred Books Starting From 25th? |
|
Answer» SELECT book_title FROM BOOKS LIMIT 25, 100. The FIRST number in LIMIT is the OFFSET, the second is the number. SELECT book_title FROM books LIMIT 25, 100. The first number in LIMIT is the offset, the second is the number. |
|
| 95. |
If The Value In The Column Is Repeatable, How Do You Find Out The Unique Values? |
|
Answer» USE DISTINCT in the query, such as SELECT DISTINCT user_firstname FROM users; You can also ask for a number of distinct values by SAYING SELECT COUNT (DISTINCT user_firstname) FROM users; Use DISTINCT in the query, such as SELECT DISTINCT user_firstname FROM users; You can also ask for a number of distinct values by saying SELECT COUNT (DISTINCT user_firstname) FROM users; |
|
| 96. |
How Do You Get The Number Of Rows Affected By Query? |
|
Answer» SELECT COUNT (user_id) FROM USERS WOULD only return the NUMBER of user_id’s. SELECT COUNT (user_id) FROM users would only return the number of user_id’s. |
|
| 97. |
What Is Ddl, Dml And Dcl ? |
|
Answer» If you look at the large variety of SQL commands, they can be divided into three large subgroups. DATA Definition Language deals with database schemas and DESCRIPTIONS of how the data should reside in the database, therefore language statements like CREATE TABLE or ALTER TABLE belong to DDL. DML deals with data manipulation, and therefore includes most common SQL statements such SELECT, INSERT, etc. Data Control Language includes commands such as GRANT, and mostly concerns with rights, PERMISSIONS and other controls of the database system. If you look at the large variety of SQL commands, they can be divided into three large subgroups. Data Definition Language deals with database schemas and descriptions of how the data should reside in the database, therefore language statements like CREATE TABLE or ALTER TABLE belong to DDL. DML deals with data manipulation, and therefore includes most common SQL statements such SELECT, INSERT, etc. Data Control Language includes commands such as GRANT, and mostly concerns with rights, permissions and other controls of the database system. |
|
| 98. |
What's Mysql ? |
|
Answer» MySQL (pronounced "my ESS cue el") is an OPEN source relational database management system (RDBMS) that uses STRUCTURED QUERY Language (SQL), the most popular language for adding, accessing, and processing data in a database. Because it is open source, anyone can download MySQL and tailor it to their needs in accordance with the general public license. MySQL is noted mainly for its speed, reliability, and flexibility. MySQL (pronounced "my ess cue el") is an open source relational database management system (RDBMS) that uses Structured Query Language (SQL), the most popular language for adding, accessing, and processing data in a database. Because it is open source, anyone can download MySQL and tailor it to their needs in accordance with the general public license. MySQL is noted mainly for its speed, reliability, and flexibility. |
|