My SQL Interview Questions and Answers
Question - 21 : - How do you get the month from a timestamp?
Answer - 21 : - SELECT MONTH(techpreparation_timestamp) from techpreparation_questions;
Question - 22 : - How do you offload the time/date handling to MySQL?
Answer - 22 : - SELECT DATE_FORMAT(techpreparation_timestamp, ‘%Y-%m-%d’) from techpreparation_questions; A similar TIME_FORMAT function deals with time.
Question - 23 : - What’s the difference between Unix timestamps and MySQL timestamps?
Answer - 23 : - 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.
Question - 24 : - What are ENUMs used for in MySQL?
Answer - 24 : - You can limit the possible values that go into the table. CREATE TABLE months (month ENUM ‘January’, ‘February’, ‘March’,…); INSERT months VALUES (’April’);
Question - 25 : - How do you start and stop MySQL on Windows?
Answer - 25 : - net start MySQL, net stop MySQL
Question - 26 : - How do you start MySQL on Linux?
Answer - 26 : - /etc/init.d/mysql start
Question - 27 : - What’s the default port for MySQL Server?
Answer - 27 : - 3306
Question - 28 : - How do you change a password for an existing user via mysqladmin?
Answer - 28 : - mysqladmin -u root -p password "newpassword"
Question - 29 : - Use mysqldump to create a copy of the database?
Answer - 29 : - mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
Question - 30 : - Have you ever used MySQL Administrator and MySQL Query Browser?
Answer - 30 : - Describe the tasks you accomplished with these tools.