MySQL Interview Questions & Answers
What is the default port for MySQL Server?
The default port for MySQL server is 3306.
What are the advantages of MySQL when compared with Oracle?
- MySQL is open source software which is available at any time and has no cost involved.
- MySQL is portable
- GUI with command prompt.
- Administration is supported using MySQL Query Browser
Differentiate between FLOAT and DOUBLE?
Following are differences for FLOAT and DOUBLE:
- Floating point numbers are stored in FLOAT with eight place accuracy and it has four bytes.
- Floating point numbers are stored in DOUBLE with accuracy of 18 places and it has eight bytes.
Differentiate CHAR_LENGTH and LENGTH?
CHAR_LENGTH is character count whereas the LENGTH is byte count. The numbers are same for Latin characters but they are different for Unicode and other encodings.
How to represent ENUMs and SETs internally?
ENUMs and SETs are used to represent powers of two because of storage optimizations.
What is the usage of ENUMs in MySQL?
ENUM is a string object used to specify set of predefined values and that can be used during table creation.
|1||Create table size(name ENUM('Small', 'Medium','Large');|
REGEXP is a pattern match in which matches pattern anywhere in the search value.
Difference between CHAR and VARCHAR?
Following are the differences between CHAR and VARCHAR:
- CHAR and VARCHAR types differ in storage and retrieval
- CHAR column length is fixed to the length that is declared while creating table. The length value ranges from 1 and 255
- When CHAR values are stored then they are right padded using spaces to specific length. Trailing spaces are removed when CHAR values are retrieved.
Give string types available for column?
The string types are:
How to get current MySQL version?
|1||SELECT VERSION ();|
is used to get the current version of MySQL.
What storage engines are used in MySQL?
Storage engines are called table types and data is stored in files using various techniques.
- Storage mechanism
- Locking levels
- Capabilities and functions.
What are the drivers in MySQL?
Following are the drivers available in MySQL:
- PHP Driver
- JDBC Driver
- ODBC Driver
- C WRAPPER
- PYTHON Driver
- PERL Driver
- RUBY Driver
- CAP11PHP Driver
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.
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.
How do you login to MySql using Unix shell?
We can login through this command:
# [mysql dir]/bin/mysql -h hostname -u <UserName> -p <password>