Mysql Interview Questions

Mysql Interview Questions

MySql is a multi-threading, multi-user open source SQL database management system. It is typically used for web application development, and often accessed using PHP.

Read Best MySql Interview Question and answers

Download Mysql Interview Questions PDF

Mysql Interview Questions

A stored procedure is a set of SQL commands that can be compiled and stored in the server. Once this has been done, clients don’t need to keep re-issuing the entire query but can refer to the stored procedure.

This provides better overall performance because the query has to be parsed only once, and less information needs to be sent between the server and the client. You can also raise the conceptual level by having libraries of functions in the server. However, stored procedures of course do increase the load on the database server system, as more of the work is done on the server side and less on the client (application) side. Triggers will also be implemented. A trigger is effectively a type of stored procedure, one that is invoked when a particular event occurs.

For example, you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that stored procedure automatically deletes the corresponding customer from a customer table when all his transactions are deleted. Indexes are used to find rows with specific column values quickly.

Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question,

MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially. If you need to access most of the rows, it is faster to read sequentially, because this minimizes disk seeks.

Run below command on the terminal to import a MySQL database from the file

mysql -u username -p database_name < file.sql 

In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record.

MySql is writen in C and C++ and SQL parser writen in yacc.

mysqli is the object-oriented version of mysql library functions.

HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and < =>. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.

Advantages of using Mysql in compared to Orcale

  • MySQL is a free, fast, reliable, open source relational database while Oracle is expensive, although they have provided Oracle free edition to attract MySQL users.
  • MySQL uses only just under 1 MB of RAM on your laptop while Oracle 9i installation uses 128 MB.
  • MySQL is great for database enabled websites while Oracle is made for enterprises.
  • MySQL is portable.

Disadvantages of MySql.

  • MySQL is not so efficient for large scale databases.
  • It does not support COMMIT and STORED PROCEDURES functions version less than 5.0.
  • Transactions are not handled very efficiently.

mysqladmin -u root -p password “newpassword”