• +91 9723535972
  • info@interviewmaterial.com

My SQL Interview Questions and Answers

My SQL Interview Questions and Answers

Question - 11 : - What does –i-am-a-dummy flag to do when starting MySQL?

Answer - 11 : - What does –i-am-a-dummy flag to do when starting MySQL? Makes the MySQL engine refuse UPDATE and DELETE commands where the WHERE clause is not present. On executing the DELETE statement I keep getting the error about foreign key constraint failing.

Question - 12 : - On executing the DELETE statement I keep getting the error about foreign key constraint failing. What do I do?

Answer - 12 : - 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.

Question - 13 : - When would you use ORDER BY in DELETE statement?

Answer - 13 : - When you’re not deleting by row ID. Such as in DELETE FROM techpreparation_com_questions ORDER BY timestamp LIMIT 1. This will delete the most recently posted question in the table techpreparation_com_questions.

Question - 14 : - How can you see all indexes defined for a table?

Answer - 14 : - SHOW INDEX FROM techpreparation_questions;

Question - 15 : - How would you change a table to InnoDB?

Answer - 15 : - ALTER TABLE techpreparation_questions ENGINE innodb;

Question - 16 : - How do I find out all databases starting with ‘exam’ to which I have access to?

Answer - 16 : - SHOW DATABASES LIKE ‘exam%’;

Question - 17 : - How do you concatenate strings in MySQL?

Answer - 17 : - CONCAT (string1, string2, string3)

Question - 18 : - What’s the difference between CHAR_LENGTH and LENGTH?

Answer - 18 : - 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.

Question - 19 : - What do % and _ mean inside LIKE statement?

Answer - 19 : - % corresponds to 0 or more characters, _ is exactly one character.

Question - 20 : - What does + mean in REGEXP?

Answer - 20 : - At least one character. Appendix G. Regular Expressions from MySQL manual is worth perusing before the interview.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners