My SQL



21. What is REGEXP?  

REGEXP is a pattern match using regular expression. Regular expression is a powerful way of specifying a pattern for a complex search.



22. How many columns can you create for an index?  

You can create maximum of 16 indexed columns for a standard table.



23. What is the difference between NOW() and CURRENT_DATE()?  

NOW() command is used to show current year, month, date with hours, minutes and seconds while CURRENT_DATE() shows the current year with month and date only.



24. What is the query to display top 20 rows?  

    SELECT * FROM table_name LIMIT 0,20;  



25. Write a query to display current date and time?  

If you want to display current date and time, use -

    SELECT NOW();  
    If you want to display current date only, use -  
    SELECT CURRENT_DATE();  


26. What is save point in MySQL?  

A defined point in any transaction is known as savepoint.

SAVEPOINT is a statement in MySQL which is used to set a named transaction save point with a name of identifier.



27. What is SQLyog?  

SQLyog program is the most popular GUI tool for admin. It is the most popular MySQL manager and admin tool. It combines the features of MySQL administrator, phpMyadmin and others MySQL front ends and MySQL GUI tools.



28. How do you backup a database in MySQl?  

It is easy to backing up data with phpMyAdmin. Select the database you want to backup by clicking the database name in the left hand navigation bar. Then click the export button and make sure that all tables are highlighted that you want to backup. Then specify the option you want under export and save the output.



29. What are the technical features of MySQL?  

MySQL database software is a client or server system which includes

  • Multithreaded SQL server supporting various client programs and libraries
  • Different backend
  • Wide range of application programming interfaces and Administrative tools


30. Why MySQL is used?  

MySQL database server is reliable, fast and very easy to use. This software can be downloaded as freeware and can be downloaded from the internet.



31. What are Heap tables?  

HEAP tables are present in memory and they are used for high speed storage on temporary basis

  • BLOB or TEXT fields are not allowed
  • Only comparison operators can be used =, <,>, = >,=<
  • AUTO_INCREMENT is not supported by HEAP tables
  • Indexes should be NOT NULL


32. 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


33. What does a TIMESTAMP do on UPDATE CURRENT_TIMESTAMP data type?  

TIMESTAMP column is updated with Zero when the table is created. UPDATE CURRENT_TIMESTAMP modifier updates the timestamp field to current time whenever there is a change in other fields of the table.



34. What is the difference between primary key and candidate key?  

Every row of a table is identified uniquely by primary key. There is only one primary key for a table.

Primary Key is also a candidate key. By common convention, candidate key can be designated as primary and which can be used for any foreign key references.



35. How do you login to MySql using Unix shell?  

We can login through this command:

# [mysql dir]/bin/mysql -h hostname -u -p



36. What is the difference between MyISAM Static and MyISAM Dynamic?  

In MyISAM static all the fields will have fixed width. The Dynamic MyISAM table will have fields like TEXT, BLOB, etc. to accommodate the data types with various lengths.

MyISAM Static would be easier to restore in case of corruption.



37. What are federated tables?  

Federated tables which allow access to the tables located on other databases on other servers.



38. What, if a table has one column defined as TIMESTAMP?  

Timestamp field gets the current timestamp whenever the row gets altered.



39. What happens when the column is set to AUTO INCREMENT and if you reach maximum value in the table?  

It stops incrementing. Any further inserts are going to produce an error, since the key has been used already.



40. How can we find out which auto increment was assigned on Last insert?  

LAST_INSERT_ID will return the last value assigned by Auto_increment and it is not required to specify the table name.



Java Interview Question

.Net Interview Question

PHP Interview Question

AngularJS Interview Questions