DBA > Interview Resource

MySQL and SQL

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45 

(Continued from previous part...)

How would you change a table to InnoDB?

ALTER TABLE techinterviews_questions ENGINE innodb;


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?

1. VARCHARs with length less than 4 become CHARs
2. CHARs with length more than 3 become VARCHARs.
3. NOT NULL gets added to the columns declared as PRIMARY KEYs
4. Default values such as NULL are specified for each column


How do I find out all databases starting with ‘tech’ to which I have access to?

SHOW DATABASES LIKE ‘tech%’;


How do you concatenate strings in MySQL?

CONCAT (string1, string2, string3)


How do you get a portion of a string?

SELECT SUBSTR(title, 1, 10) from techinterviews_questions;


What’s the difference between CHAR_LENGTH and LENGTH?

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.


How do you convert a string to UTF-8?

SELECT (techinterviews_question USING utf8);


What do % and _ mean inside LIKE statement?

% corresponds to 0 or more characters, _ is exactly one character.

(Continued on next part...)

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45