Top MySql Interview Questions And Answers
|Targeted towards||Internet servers & Open Source software||Corporate & Enterprise market|
|Functionality||Speed||Administration, Graphical data modelling|
|Works with||Assumes internet access||Administration, Graphical data modelling|
SQL Server is one of the Database Management Systems (DBMS) and is designed by Microsoft. DBMS are computer software applications with the capability of interacting with user, various other applications as well as the database itself. The objective is capturing and analyzing data and manages definition, querying, creation, updating as well as administration of database.
3. How and why use it?
SQL Server is free and anyone can download and use it. The application uses SQL (Structured Query Language) and is easy to use.
MySQL provides cross-platform support, wide range of interfaces for application programming and has many stored procedures like triggers and cursors that helps in managing the database.
In either Windows or POSIX systems the named pipes provide ways of inter-process communications to connect different processes running on the same machine. It dispenses with the necessity of using the network stack and data can be sent without affecting the performance. Servers set up named pipes to listen to requests. Client process needs to know the specific pipe name to send the request.
The default port for MySQL Server is 3306. Another standard default is port 1433 in TCP/IP for SQL Server.
DDL is the abbreviation for Data Definition Language dealing with database schemas as well as the description of how data resides in the database. An example is CREATE TABLE command. DML denotes Data Manipulation Language such as SELECT, INSERT etc. DCL stands for Data Control Language and includes commands like GRANT, REVOKE etc.
In MySQL the Joins are used to query data from two or more tables. The query is made using relationship between certain columns existing in the table. There are four types of Joins in MySQL. Inner Join returns the rows if there is at least one match in both the tables. Left Join returns all the rows form the left table even if there is no match in the right table. Right Join returns all the rows from the right table even if no matches exist in left table. Full Join would return rows when there is at least one match in the tables.
Common MySQL functions are as follows: • NOWO – function for returning current date and time as single value. • CURRDATEO – function for returning the current date or time. • CONCAT (X, Y) – function to concatenates two string values creating single string output. • DATEDIFF (X, Y) – function to determine difference two dates.
When the table is created, CHAR is used to define the fixed length of the table and columns. The length value could be in the range of 1-255. VARCHAR command is given to adjust the column and table length as required.
Basically HEAP tables are in-memory and used for high speed temporary storages. But TEXT or BLOB fields are not allowed within them. They also do not support AUTO INCREMENT.
The syntax for concatenating tables is MySQL is CONCAT (string 1, string 2, string 3)
The maximum limits of indexed columns that could be created for any table is 16.
Different types of strings that can be used for database columns are SET, BLOB, VARCHAR, TEX, ENUM, and CHAR.
The syntax for getting the current version of MySQL is SELECT VERSION ();
MySQLi is the object oriented version of MySQL and it interfaces in PHP.
Storage tables are named as table types. The data is stored in the files using multiple techniques such as indexing, locking levels, capabilities and functions.
Primary key in MySQL is use to identify every row of a table in unique manner. For one table there is only one primary key. One of the candidate keys is the primary key and the candidate keys can be used to reference the foreign keys.
MyISAM is the default table that is based on the sequential access method.
- HEAP is the table that is used for fast data access but data will be lost if the table or system crashes.
- InoDB is the table that supports transactions using the COMMIT and ROLL BACK commands.
- BDB can support transactions similar to InoDB but the execution is slower.
Yes, the syntax for using MySQL with LINUX operating system is /etc/init.d/mysqlstart
Use of ENUM will limit the values that can go into a table. For instance; the user can create a table giving specific month values and other month values would not enter into the table.
The following TRIGGERS are allowed in MySQL:• BEFORE INSERT
- AFTER INSERT
- BEFORE UPDATE
- AFTER UPDATE
- BEFORE DELETE
- AFTER DELETE
- LIKE is denoted using the % sign. For example:SELECT * FROM user WHERE user name LIKE “%NAME”.• On the other hand the use of REGEXP is as follows:SELECT * FROM user WHERE username REGEXP “^NAME”;
Information that is provided on the slow query log could be huge in size. The query could also be listed over thousand times. In order to summarize the slow query log in an informative manner one can use the third party tool “pt-qury-digest”.
User can take incremental backup in MySQL using percona xtrabackup.
In such cases when the password is lost the user should start the DB with – skip-grants-table and then change the password. Thereafter with the new password the user should restart the DB in normal mode.
When the data disk is full and overloaded the way out is to create and soft link and move the .frm as well as the .idb files into that link location.
Basically DELETE TABLE is logged operation and every row deleted is logged. Therefore the process is usually slow. TRUNCATE TABLE also deletes rows in a table but it will not log any of the rows deleted. The process is faster in comparison. TRUNCATE TABLE can be rolled back and is functionally similar to the DELETE statement using no WHERE clause.
There are four types of Joins in MySQL. Inner Join returns the rows if there is at least one match in both the tables. Left Join returns all the rows form the left table even if there is no match in the right table. Right Join returns all the rows from the right table even if no matches exist in left table. Full Join would return rows when there is at least one match in the tables.
The storage models in OLA are MOLAP, ROLAP, and HOLAP.
For this it is necessary reviewing the layered architecture and determining hardware and software configuration dependencies in respect of the application put to test.
While both are used to enforce uniqueness of the column defined but primary key would create a clustered index whereas unique key would create non-clustered index on the column. Primary key does not allow ‘NULL’ but unique key allows it.
Transaction is logical unit of work where either all or none of the steps should be performed. ACID is the abbreviation for Atomicity, Consistency, Isolation, and Durability that are properties of any transaction.
The command line SQLSERVER.EXE used with –m will restart SQL Server in single user mode and with –f will start it in minimal configuration mode.
BLOBs are binary large object holding huge data. 4 types of BLOB are TINYBLOB, BLOB, MEDIBLOB, and LONGBLOB. TEXT is case-sensitive BLOB. 4 types of TEXT are TINY TEXT, TEXT, MEDIUMTEXT, and LONG TEXT.
The logical architecture of MySQL is made of ‘connection manager’, ‘query optimizer’, and ‘pluggable engines’.