MYSQL Questions and Answers
1. What is MySQL?
|MySQL is an open source DBMS which is built, supported and distributed by MySQL AB (now acquired by Oracle)|
2. How do you get the number of rows affected by query?
|SELECT COUNT (user_id) FROM users would only return the number of user_id’s.|
3. How do you start MySQL on Linux?
4. What is the default port for MySQL Server?
|The default port for MySQL server is 3306.|
5. How would you write a query to select all teams that won either 2, 4, 6 or 8 games?
|SELECT team_name FROM teams WHERE team_won IN (2, 4, 6, 8)|
6. How to represent ENUMs and SETs internally?
|ENUMs and SETs are used to represent powers of two because of storage optimizations.|
7. How do you offload the time/date handling to MySQL?
|SELECT DATE_FORMAT(techpreparation_timestamp, ‘%Y-%m-%d’) from techpreparation_questions; A similar TIME_FORMAT function deals with time.|
8. Define REGEXP?
|REGEXP is a pattern match in which matches pattern anywhere in the search value.|
9. How do you convert between Unix timestamps and MySQL timestamps?
|UNIX_TIMESTAMP converts from MySQL timestamp to Unix timestamp, FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp.|
10. What storage engines are used in MySQL?
|Storage engines are called table types and data is stored in files using various techniques. Technique involves: Storage mechanism Locking levels Indexing Capabilities and functions.|