100% found this document useful (1 vote)
39 views

Interview Questions PHP Mysql

The document contains questions and answers related to PHP and MySQL. It discusses various PHP functions like echo, trim(), explode(), include(), exit(), isset(), unset(), and concepts like data types in PHP, frameworks, error types, GET and POST methods, static and dynamic websites, magic functions, and more. It also covers MySQL topics such as creating a database, data retrieval methods, features of MySQL, data types, and table types.

Uploaded by

A B Sagar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
39 views

Interview Questions PHP Mysql

The document contains questions and answers related to PHP and MySQL. It discusses various PHP functions like echo, trim(), explode(), include(), exit(), isset(), unset(), and concepts like data types in PHP, frameworks, error types, GET and POST methods, static and dynamic websites, magic functions, and more. It also covers MySQL topics such as creating a database, data retrieval methods, features of MySQL, data types, and table types.

Uploaded by

A B Sagar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

1. Explain Echo?

The echo can take more than one string for output and return 1.

2. What is the name of the Script Engine in PHP?


Zend Engine 2

3. What is the trim() function?


It removes the predefined characters and white space from two sides of the string.

4. What ways can we retrieve data? On the result sets of MySql using PHP?
There are four ways to retrieve and they are

 mysql_fetch_row
 mysql_fetch_assoc
 mysql_fetch_array
 mysql_fetch_object

5. What is the limitation of print?


The Print can take only one argument as the parameter.

6. What is an in_array() function?


This function scans the complete array to find a specific value.

7. What are the uses of count() function in PHP?


This function is used in counting all the elements in the array.

8. How can we include the file to the PHP page?


We could include the file to the PHP page using a require() or include() function with the file path as their
parameter.

9. How do you create a Database using MySQL and PHP?


We can create the MySQL Database by using mysql_create_db (“Database Name”)

10. List three features of MySQL?


MySQL is easy and reliable for use. MySQL supports various programming languages like PHP, Java, Perl, and
C++. MySQL supports standard SQL that means (Structured Query Language). These types of PHP and
MySQL Interview Questions for fresher in an Interview.

11. What is the Language MySQL is been written with?

 MySQL – C, C++
 SQL parser – Yacc.

12. Mention technical specifications of MySQL?

 Drivers
 JSON Support
 Graphical Tools
 Flexible structure
 High performance
 Geo-Spatial Support
 OLTP and Transactions
 MySQL Enterprise Monitor
 MySQL Enterprise Security
 Manageable and easy to use
 Replication & High-Availability
 Manageability and Ease of Use
 Replication and high availability
 Security and storage management

13. What are the Data Types in PHP?


Under Compound types

 Array
 Object
 Callable
Under Scalar types

 Float
 String
 Integer
 Boolean
Under Special types

 Null
 Resource

14. Mention the frameworks in PHP?

 Yii 2
 Symfony
 CakePHP
 CodeIgniter
 Zend Framework

15. What is unset() ?


An unset() function sets variable to “undefined”.

16. What are the three main error types?

 Fatal
 E-Notices
 E-Warnings

17. How will you get an IP address for a client?


$_SERVER[“REMOTE_ADDR”];

18. What is the explode function?


It can convert the string to an array with the delimiter.

19. How do you stop the execution of the PHP Script?


By using Exit(); function.
20. Define the Implode function.
Implode function is converse of the Explode function. It implodes the array into a string. These are the Basic
PHP and MySQL Interview Question and Answers that are asked to freshers in an Interview.

21. What are the Consonants in PHP?


-FILE- -LINE- -CLASS- -METHOD- -FUNCTION-

22. Mention the table name that is present in MySQL?

 ISAM
 Heap
 Merge
 MyISAM
 INNO DB

23. What are the uses of PHP?

 It can gather the data from files, save those data to a file and also we can send those data through email.

 One could delete, add, and modify elements within the database by using PHP.

 We can access the cookies variables.

24. List the pro features of PHP MySQL?

 Data Security
 On-Demand Scalability
 High Performance
 Round-the-clock
 Complete Workflow Control
 Flexibility on Open Source
 Comprehensive Transactional Support

25. Define PHP 5?


This is a Server Script language. It is used in making dynamic and interactive web pages. Besides, it is a free
and useful alternative for its competitor like Microsoft’s ASP.

26. Define Static Websites.


The content of a Static Website could not be changed once if we run the scripts. Also, we can’t change anything
on this site as they are predefined.

27. What are Dynamic Websites?


The scripts of the Dynamic websites could be changed at run time. The content is regenerated constantly after
the user’s visit or reloads.

28. What are the Magic Functions that are available in the PHP?
_destruct() _call() _get() _set() _isset() _unset() _construct() _sleep() _clone() _invoke() _to string _wakeup()
_set-state() _debuginfo()

29. How do you stop executing a PHP Script?


exit(); function.
30. What is an isset () function?
It is used for checking whether the variable is set and if it is not null.

31. What is the way to destroy the variable or object?


Unset() function.

32. What is the MIME types is required for sending the attachment mail?
Multipart/ mixed.

33. What are the various types of triggers that are possible in MySQL?

 Before Insert
 After Insert
 Before Delete
 After Delete
 Before Update
 After Update

34. What is the session time of PHP?


It will last for 24 minutes(1440 seconds).

35. Mention the uses of PHP and MySQL?


PHP: It is the scripting language and used in Web Development. MySQL: MySQl is a Relational Database
Management System.

36. What is a TEXT and Blob in MySQL?


Blob: It is the acronym of the large binary object. It is used in holding the amount of variable data. Text: It is
the case-sensitive Blob. Text values are not binary strings. It has a character set, values stored and compared to
based on the relation of a character set.

37. What are the types of Blob?

 BLOB
 TINYBLOB
 LONGBLOB
 MEDIUMBLOB

38. What are the types of TEXT in MySQL?

 TEXT
 TINY TEXT
 MEDIUM TEXT
 LONGTEXT

39. Name the variable’s scope in PHP?

 Local Scope
 Global Scope
 Static Scope

40. How would you redirect the page in PHP?


header(“Location:HomePage.php”); These are the Basic PHP and MySQL Interview Questions that are asked to
a fresher and Experienced candidate in an Interview.

41. List any three Disadvantages of MySQL?

 They are not sufficient for large scale databases.


 MySQL cannot support STORED PROCEDURES and COMMIT function version which is lesser than
5.0.
 The functionality of MySQL is primarily dependent on the addons.

42. How to destroy a cookie?


By setting cookies in the past.

43. What are the possible ways to pass the variable via navigation between pages?


o GET/QueryString
o POST

44. What is the one main distinction between PHP4 and PHP5
PHP5 can present various additional Object-Oriented Programming (OOP) features compared to PHP4.

45. What is the function used in removing the escape characters from the string?
stripslashes function.

46. What are the functions used in sorting the Array?

 Sort()
 asort()
 arsort()
 ksort()
 rsort()
 usort()
 natsort()
 natcasesort()
 uksort()
 array_multisort()

47. Which method is used in sending the Simple Mail Transfer Protocol using PHP?
mail($EmailAddress, “Subject”, $MessageBody);.

48. From the statements that are given below which one is correct?
When $x = null;

 empty($x) return TRUE


 isset($x) return FALSE
 is_null($x) return FALSE
None of the Statements are correct.

49. What is the immediate way to escape the incoming data?


We can enable the magic quote entry on the configuration file of the PHP.
50. Mention the method that is used in tweaking a object’s cloning behavior?
__clone() These are the Basic PHP and MySQL Interview Question and Answers that are asked to a fresher in
an Interview.

51. How can you get the recent date of MySQL?


For getting the current date, we could use the following syntax, SELECT CURRENT_DATE();

52. What is the default port number of MySQL?


3306 is the default port number of MySQL

53. Name the tools through which we could draw E- diagrams for MySQL.

 Case Studio
 Smart Draw

54. List a few functions of the Imap?

 imap_body – Reads the body message


 imap_check – Checks the current mailbox
 imap_delete – Marks the message for deletion from the present mailbox
 imap_mail – Sends an email as a message.

55. What are the current versions of MySQL and PHP?


Current versions of MySQL and PHP are

 MySQL – 5.0
 PHP – 5.1 Beta

56. What are the types of Array in PHP?

 Indexed Array
 Associative Array
 Multi-Dimensional Array

57. What are the built-in functions that will add value to the end of an array?

 into_array()
 inend_array()
 array_push()
 array_unshift()

58. What are the features of PHP7?

 Spaceship operator
 Generator delegation
 Anonymous classes
 Closure:: call method
 Group use declaration
 Scalar type declarations
 Return type declarations
 Null coalescing operator (??)
 Constant arrays using define()
 Generator return expressions.

59. List the Content Management Systems in PHP?

 WordPress
 Joomla
 Magento
 Drupal

60. How many columns we can create for the index?


For a Standard Table, we can create 16 indexed columns. These are the Common PHP Interview Questions that
are asked to Experienced candidate in an Interview.

61. How can you check whether the value of the given variable is number or not?
We can use is_numeric for checking whether they are number or not.

62. What function can be used in determining whether a file exists?

 feof()
 is_readable()
 file_exists()
 is_file_exists()

63. Which of the following is not a valid Simple XML Parser method?

 simplexml_import_dom()
 simplexml_import_sax()
 simplexml_load_file()
 simplexml_load_string()
The function simplexml_import_sax() is not valid.

64. How objects are passed either by reference or value?


Passed by value.

65. How to pass variable by value?


We can put the “&” Ampersand in front of the value.

66. What is the query for displaying the top 20 rows?


Select* From table_name Limit 0 -20;

67. Define the Associative Array.


The Array with Strings as an index is known as an associative array.

68. From the below statements which of the following would produce the value of “83” as their
output?

 echo intval(“0123”, 8);


 echo intval(“0123”);
 echo (int) 083
echo intval(“0123”, 8); will produce 83 as their output.
69. Define Multidimensional Array.
An Array which contains more than 1 array is called a Multidimensional array. Also, the values can be accessed
using various indices.

70. Elucidate SQL Injection?


The SQL injection is code injection technique. It is used in attacking data-driven applications

71. From the below cURL which of them is not a valid parameter PHP?

CURLOPT_RETURNTRANSFER
CURLOPT_GET
CURLOPT_POST
CURLOPT_RETURNTRANSFER is not the valid cURL.

72. Name the functions that are used for searching the strings using the POSIX-style regular
expression?

 sql_regcase()
 eragi_replace()
 ereg_replace()
 spliti()
 erag()
sql_regcase() and ereg_replace() functions are used.

73. How can we sort array in the reverse order?


By using “ksort”.

74. What is the role of MySQL check?


It is a Client program that is used in checking the integrity of the database tables.

75. What is TimeStamp?


They are the data type that can show the automatically generated binary numbers.Timestamp is used as the
mechanism for the version of stamping table rows. Join PHP Training in Bangalore at FITA and upskill your
knowledge in PHP programming language with market-relevant skills.

76. Mention the advantages of the InnoDB over MyISAM?

 The Advantages include,


 Transactions
 Row-level locking
 Crash Recovery
 Foreign key Constraints.

77. Which one is not a valid method in PHP XML DOM?

 geElementByName()
 removeChild()
 geElementById()
 appendChild()
geElementById() is not a valid method in the PHP XML DOM.
78. What is the role of a LAMP in PHP?
It is the combination of Linux, Apache, PHP, and MySQL.

79. What is the meaning of Self in PHP?


It is the Self keyword that is used in accessing the static methods and properties.

80. Explain MySQL dump?


This is the client program and it creates logical database backups. These are the Basic MySQL Interview
Questions that are asked to a fresher and experienced candidate in an Interview.

81. What is the Scope level in PHP?

 Private
 Public
 Protected

82. What is the limit of the identifiers in MySQL?

 Table 64bytes
 Index 64 bytes
 Column 64 bytes
 Database 64 bytes
 Alias 255 bytes

83. How can we identify the current session ID?


session_id()

84. Can PHP support different inheritances?


No

85. What are the various types of operators available in PHP?

 Union
 Union All
 Minus
 Intersect

86. Explain White Box Testing?


It deals with tables, schema, data model, and referential integrity rules. They also deal with a logical view
supporting database consistency, triggers, and ACID properties.

87. Elucidate CTE?


Common Table Expression consists of a temporary set of results which are defined in the SQL statement.

88. List the encryption functions that are available in PHP?

 crypt()
 Mcrypt()
 hash()

89. What are the various types of print functions that are available in PHP?
 print() Function
 printf() Function
 echo() Function
 print_r() Function
 sprintf() Function

90. Explain Composer in PHP?


It is the package manager for the application-level in PHP. Composer permits you to declare libraries depending
on the project and also they will allow you to update. These are the Common PHP and MySQL Interview
Questions that are asked to freshers and experienced candidates in an Interview.

91. What is an action attribute in the HTML form?


It determines the place where to send a form-data on the form-submission.

92. How would you protect the special characters in the query string?
We can protect using urlencode() function.

93. What is Exception::getmessage?


It permits us to receive the Exception message.

94. How would you remove the white-space from the start till the end of the $string variable?
We can use trim($string);

95. Mention the default time session in PHP?


Until we close browser.

96. Differentiate between PHP and Java


Criterion PHP Java
Deployment area Server-Side Scripting language General Purpose Programming language
Supports Rich APIs No Yes
Language Type Dynamically typed Statically typed.

97. Differentiate between HTML and PHP?


HTML is the language that is used in describing the browser to display the text and objects in the browser
window. HTML mostly works on client computers and they are not a programming language. Whereas PHP is a
scripting language and it could be used in creating web pages that are written in HTML.

98. Elucidate polymorphism in PHP?


It describe patterns in object-oriented programming. Where the classes have multiple functionality when sharing
the common interface.

99. Mention the use of die in PHP?


This function prints the message, exists in the current script.

100. Write the syntax of the mail() function in PHP?


mail($to,$subject,$message,$headers)These are the Basic PHP and MySQL Interview Questions and Answers
that are asked to a fresher in an Interview.

101. List the general MYSQL functions?

 NOWO
 CURRDATEO
 CONCAT (X, Y)
 DATEDIFF (X, Y)

1) What is MySQL?

MySQL is an open-source Database Management System (DBMS) for managing and organizing the data in a
tabular format, These data can be manipulated using MySQL programming language. It supported and
distributed by MySQL AB (now acquired by Oracle)

2) 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.

3) 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.

4) 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

5) What is the default port for MySQL Server?

The default port for MySQL server is 3306.

6) 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

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

8) 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.

9) How to represent ENUMs and SETs internally?

ENUMs and SETs are used to represent powers of two because of storage optimizations.

10) 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.
Create table size(name ENUM('Small', 'Medium','Large');

11) Define REGEXP?

REGEXP is a pattern match in which matches pattern anywhere in the search value.

12) 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.

13) Give string types available for column?

The string types are:

 SET
 BLOB
 ENUM
 CHAR
 TEXT
 VARCHAR

14) How to get current MySQL version?


SELECT VERSION ();

is used to get the current version of MySQL.

15) 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.

16) 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
 Ado.net5.mxj

17) 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.

18) 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.

19) 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>

20) What does myisamchk do?

It compress the MyISAM tables, which reduces their disk or memory usage.

21) How do you control the max size of a HEAP table?

Maximum size of Heal table can be controlled by MySQL config variable called max_heap_table_size.

22) 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.

23) What are federated tables?

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

24) What, if a table has one column defined as TIMESTAMP?

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

25) 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.

26) 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.
27) How can you see all indexes defined for a table?

Indexes are defined for the table by:


SHOW INDEX FROM <tablename>;

28) What do you mean by % and _ in the LIKE statement?

% corresponds to 0 or more characters, _ is exactly one character in the LIKE statement.

29) How can we convert between Unix & MySQL timestamps?

UNIX_TIMESTAMP is the command which converts from MySQL timestamp to Unix timestamp

FROM_UNIXTIME is the command which converts from Unix timestamp to MySQL timestamp.

30) What are the column comparisons operators?

The = , <>, <=, <, >=, >,<<,>>, <=>, AND, OR, or LIKE operators are used in column comparisons in
SELECT statements.

31) How can we get the number of rows affected by query?

Number of rows can be obtained by


SELECT COUNT (user_id) FROM users;

32) Is Mysql query is case sensitive?

No.
SELECT VERSION(), CURRENT_DATE;
SeLect version(), current_date;
seleCt vErSiOn(), current_DATE;

All these examples are same. It is not case sensitive.

33) What is the difference between the LIKE and REGEXP operators?

LIKE and REGEXP operators are used to express with ^ and %.


SELECT * FROM employee WHERE emp_name REGEXP "^b";
SELECT * FROM employee WHERE emp_name LIKE "%b";

34) What is the difference between BLOB AND TEXT?

A BLOB is a binary large object that can hold a variable amount of data. There are four types of BLOB –

 TINYBLOB
 BLOB
 MEDIUMBLOB and
 LONGBLOB

They all differ only in the maximum length of the values they can hold.

A TEXT is a case-insensitive BLOB. The four TEXT types

 TINYTEXT
 TEXT
 MEDIUMTEXT and
 LONGTEXT

They all correspond to the four BLOB types and have the same maximum lengths and storage requirements.

The only difference between BLOB and TEXT types is that sorting and comparison is performed in case-
sensitive for BLOB values and case-insensitive for TEXT values.

35) What is the difference between mysql_fetch_array and mysql_fetch_object?

Following are the differences between mysql_fetch_array and mysql_fetch_object:

mysql_fetch_array() -Returns a result row as an associated array or a regular array from database.

mysql_fetch_object – Returns a result row as object from database.

36) How can we run batch mode in mysql?

Following commands are used to run in batch mode:


mysql ;
mysql mysql.out

37) Where MyISAM table will be stored and also give their formats of storage?

Each MyISAM table is stored on disk in three formats:

 The ‘.frm’ file stores the table definition


 The data file has a ‘.MYD’ (MYData) extension
 The index file has a ‘.MYI’ (MYIndex) extension

38) What are the different tables present in MySQL?

Total 5 types of tables are present:

 MyISAM
 Heap
 Merge
 INNO DB
 ISAM

MyISAM is the default storage engine as of MySQL.

39) What is ISAM?

ISAM is abbreviated as Indexed Sequential Access Method.It was developed by IBM to store and retrieve data
on secondary storage systems like tapes.

40) What is InnoDB?

lnnoDB is a transaction safe storage engine developed by Innobase Oy which is a Oracle Corporation now.

41) How MySQL Optimizes DISTINCT?

DISTINCT is converted to a GROUP BY on all columns and it will be combined with ORDER BY clause.
SELECT DISTINCT t1.a FROM t1,t2 where t1.a=t2.a;

42) How to enter Characters as HEX Numbers?

If you want to enter characters as HEX numbers, you can enter HEX numbers with single quotes and a prefix of
(X), or just prefix HEX numbers with (Ox).

A HEX number string will be automatically converted into a character string, if the expression context is a
string.

43) How to display top 50 rows?

In MySql, top 50 rows are displayed by using this following query:


SELECT * FROM
LIMIT 0,50;

44) How many columns can be used for creating Index?

Maximum of 16 indexed columns can be created for any standard table.

45) What is the different between NOW() and CURRENT_DATE()?

NOW () command is used to show current year,month,date with hours,minutes and seconds.

CURRENT_DATE() shows current year,month and date only.


46) What are the objects can be created using CREATE statement?

Following objects are created using CREATE statement:

 DATABASE
 EVENT
 FUNCTION
 INDEX
 PROCEDURE
 TABLE
 TRIGGER
 USER
 VIEW

47) How many TRIGGERS are allowed in MySql table?

SIX triggers are allowed in MySql table. They are as follows:

 BEFORE INSERT
 AFTER INSERT
 BEFORE UPDATE
 AFTER UPDATE
 BEFORE DELETE and
 AFTER DELETE

48) What are the nonstandard string types?

Following are Non-Standard string types:

 TINYTEXT
 TEXT
 MEDIUMTEXT
 LONGTEXT

49) What are all the Common SQL Function?

CONCAT(A, B) – Concatenates two string values to create a single string output. Often used to combine two or
more fields into one single field.

FORMAT(X, D) – Formats the number X to D significant digits.

CURRDATE(), CURRTIME() – Returns the current date or time.

NOW() – Returns the current date and time as one value.

MONTH(), DAY(), YEAR(), WEEK(), WEEKDAY() – Extracts the given data from a date value.

HOUR(), MINUTE(), SECOND() – Extracts the given data from a time value.
DATEDIFF(A, B) – Determines the difference between two dates and it is commonly used to calculate age

SUBTIMES(A, B) – Determines the difference between two times.

FROMDAYS(INT) – Converts an integer number of days into a date value.

50) Explain Access Control Lists.

An ACL (Access Control List) is a list of permissions that is associated with an object. This list is the basis for
MySQL server’s security model and it helps in troubleshooting problems like users not being able to connect.

MySQL keeps the ACLs (also called grant tables) cached in memory. When a user tries to authenticate or run a
command, MySQL checks the authentication information and permissions against the ACLs, in a predetermined
order.

1. What is SQL Server?

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 users, various other applications, and
databases. The objective of SQL Server is capturing and analyzing data and managing the definition, querying,
creation, updating, and administration of the database.
Learn PHP and MySQL from industry experts. Enroll now in PHP and MySQL Training

2. Compare MySQL vs SQL Server.


Criteria MySQL SQL Server
Developed by Oracle Microsoft
Programmed in C and C++ Mainly C++, but some parts in C
Platforms Supports many platforms Supports only Linux and Windows
Syntax Complex Syntax Simpler and easy-to-use syntax

3. How and why use SQL Server?

SQL Server is free and anyone can download and use it. The application uses SQL (Structured Query
Language), and it is easy to use.

Get 100% Hike!

Master Most in Demand Skills Now !

4. What are the features of MySQL?

MySQL provides cross-platform support, a wide range of interfaces for application programming, and has many
stored procedures like triggers and cursors that help in managing the database.

5. What are the advantages and disadvantages of using MySQL?

There are various advantages and disadvantages of using MySQL. Some of them are given below:
Advantages

 MySQL helps in the secure management of databases. By using it, we can securely execute database
transactions.
 It is fast and efficient in comparison to other database management systems as it supports varieties of storage
engines.
 As its transaction processing is high, MySQL can execute millions of queries.

Besides, some of the features that make MySQL unique are deadlock identification, execution of multiple
transactions, efficient processing, and easy management.

Disadvantages

 Scalability in MySQL is a redundant task.


 MySQL serves good for large databases mostly.
 There are issues of the instability of software.

6. What is the basic MySQL architecture?

The logical architecture of MySQL is made of ‘connection manager’, ‘query optimizer’, and ‘pluggable
engines’.

7. What is the Traditional Network Library for a system?

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.
The client process needs to know the specific pipe name to send the request.

8. What is the default port for MySQL Server?

The default port for MySQL Server is 3306. Another standard default port is 1433 in TCP/IP for SQL Server.

9. What do DDL, DML, and DCL stand for?

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 of this is the CREATE TABLE command. DML denotes Data
Manipulation Language which includes commands such as SELECT, INSERT, etc. DCL stands for Data
Control Language and includes commands like GRANT, REVOKE, etc.
10. What is a join in MySQL?

In MySQL, joins are used to query data from two or more tables. The query is made using the relationship
between certain columns existing in the table. There are four types of joins in MySQL.

Inner join returns rows if there is at least one match in both tables. Left join returns all the rows from 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 the left table. Full join would return rows when there is at least one match in the tables.

Master SQL concepts in depth from this SQL Tutorial now!


11. What are the common MySQL functions?

Common MySQL functions are as follows:

 NOWO: The function for returning the current date and time as a single value
 CURRDATEO: The function for returning the current date or time
 CONCAT (X, Y): The function to concatenate two string values creating a single string output
 DATEDIFF (X, Y): The function to determine the difference between two dates

Check out Intellipaat’s blog to get a fair understanding of SQL Optimization Techniques!

12. What is the difference between CHAR and VARCHAR?

When a 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. The VARCHAR command is used to adjust the column and table lengths as
required.
Are you looking to become an MS SQL Server DBA Expert? Go through Intellipaat’s MS SQL Server DBA Training in
Hyderabad!

Intermediate MySQL Interview Questions and Answers

13. What are Heap Tables?

Basically, Heap tables are in-memory tables used for high-speed temporary storage. But, TEXT or BLOB fields
are not allowed within them. They also do not support AUTO INCREMENT.

14. What is the syntax for concatenating tables in MySQL?

The syntax for concatenating tables in MySQL:


CONCAT (string 1, string 2, string 3)

15. What is the limit of indexed columns that can be created for a table?

The maximum limit of indexed columns that can be created for any table is 16.

16. What are the different types of strings used in database columns in MySQL?

In MySQL, the different types of strings that can be used for database columns are SET, BLOB, VARCHAR,
TEXT, ENUM, and CHAR.

17. How can a user get the current SQL version?

The syntax for getting the current version of MySQL:


SELECT VERSION ();

18. What is the difference between primary key and unique key?

While both are used to enforce the uniqueness of the column defined, the primary key would create a clustered
index, whereas the unique key would create a non-clustered index on the column. The primary key does not
allow ‘NULL’, but the unique key does.
19. Is there an object-oriented version of MySQL library functions?

Yes. MySQLi is the object-oriented version of MySQL, and it interfaces in PHP.

20. What is the storage engine used for MySQL?

Storage tables are named table types. The data is stored in the files using multiple techniques such as indexing,
locking levels, capabilities, and functions.

Check out our comprehensive MySQL tutorial now and master the most widely used open-source relational
database management system.

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

The primary key in MySQL is used to identify every row of a table in a unique manner. For one table, there is
only one primary key. The candidate keys can be used to reference the foreign keys. One of the candidate keys
is the primary key.
22. What are the different types of tables in MySQL?

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 the data will be lost if the table or the system crashes.
 InnoDB is the table that supports transactions using the COMMIT and ROLLBACK commands.
 BDB can support transactions similar to InnoDB, but the execution is slower.

23. What are the differences between a primary key and a foreign key?
Primary Key Foreign Key
It helps in the unique identification of data in It helps establish a link between
a database tables
There can be more than one foreign
There can be only one primary key for a table
key for a table
Primary key attributes cannot have duplicate Duplicate values are acceptable for
values in a table a foreign key
Null values are not acceptable Null values are acceptable
We can define primary key constraints for It cannot be defined for temporary
temporarily created tables tables
The primary key index is automatically The index is not created
created automatically

24. What is the use of ENUM in MySQL?

The use of ENUM will limit the values that can go into a table. For instance, a user can create a table giving
specific month values and other month values would not enter into the table.

Thinking of opting for one of the Database Courses? Intellipaat is the right choice for you!

25. What are the TRIGGERS that can be used in MySQL tables?

Following TRIGGERS are allowed in MySQL:


 BEFORE INSERT
 AFTER INSERT
 BEFORE UPDATE
 AFTER UPDATE
 BEFORE DELETE
 AFTER DELETE

26. What is the difference between LIKE and REGEXP operators in MySQL?

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”;

27. How to use the MySQL slow query log?

Information that is provided on the slow query log could be huge in size. The query could also be listed over a
thousand times. In order to summarize the slow query log in an informative manner, one can use the third-party
tool ‘pt-query-digest’.

28. How can you change the root password if it is lost?

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 a normal mode.

29. How to resolve the problem of the data disk that is full?

When the data disk is full and overloaded, the way out is to create and soft link and move the .frm and the .idb
files into that link location.

30. What is the difference between the DELETE TABLE and TRUNCATE TABLE
commands in MySQL?

Basically, DELETE TABLE is a 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 here in comparison. TRUNCATE TABLE can be rolled back and is functionally similar to the
DELETE statement without a WHERE clause.

31. What are the types of joins in MySQL?

There are four types of joins in MySQL. Inner join returns the rows if there is at least one match in two tables.
Left join returns all the rows from 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 the left table. Full join would return rows when there is
at least one match in the tables.

32. What are the storage models of OLAP?

The storage models in OLAP are MOLAP, ROLAP, and HOLAP.


33. How to define the testing of network layers in MySQL?

For this, it is necessary to review the layered architecture and determine hardware and software configuration
dependencies with respect to the application put to test.

34. How can one take an incremental backup in MySQL?

A user can take an incremental backup in MySQL using Percona XtraBackup.

35. What is meant by transaction? What are ACID properties?

A transaction is a 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.

36. How can one restart SQL Server in the single user or the minimal configuration modes?

The command line SQLSERVER.EXE used with ‘–m’ will restart SQL Server in the single-user mode and the
same with ‘–f’ will restart it in the minimal configuration mode.

37. What is the difference between BLOB and TEXT?

BLOBs are binary large objects holding huge data. Four types of BLOBs are TINYBLOB, BLOB,
MEDIBLOB, and LONGBLOB. TEXT is a case-sensitive BLOB. Four types of TEXT are TINY TEXT,
TEXT, MEDIUMTEXT, and LONG TEXT.

38. Can you use MySQL with Linux operating system?

Yes. The syntax for using MySQL with Linux operating system is as follows:

etc/init.d/mysqlstart

39. What is the TIMESTAMP data type?

Timestamp in SQL Server helps in row versioning. Row versioning is a type of concurrency that allows
retaining the value until it is committed in the database. It shows the instant time of any event. It consists of
both the date and time of the event. Also, timestamp helps in backing up data during the failure of a transaction.

While we insert, update, or delete a record, the date and time automatically get inserted.

 Format of timestamp: YYYY-MM-DD HH:MM: SS


 Range of timestamp: “1970-01-01 00:00:01” UTC to “2038-01-19 03:14:07” UTC

40. What is the function of mysqldump?

As the name suggests, mysqldump is used to dump one or more created databases. It performs backups for data
or transfers the data from SQL Server to another. Also, it helps in producing the initial database schema by
logical backups. Moreover, unlike triggers, mysqldump does not backup the stored procedures or functions by
default.

Syntaxes
For a single database:
mysqldump [options] db_name [tables]

For multiple databases:


mysqldump [options] –databases db1 [db2 db3...]

For all databases:


mysqldump [options] –all-databases

41. What is an access control list?

Every organization has some crucial data specific to its business. This data needs secure access so that any
consequence due to data loss can be avoided. For this, organizations create a sequence of permissions that are
linked to various data objects. These lists are known as the access control list (ACL).

ACL serves as the basis for the server’s security that helps troubleshoot the connection problems for users.
These are also known as grant tables that are cached by MySQL. MySQL verifies a user for authentication and
grants permissions in a sequence when the user executes a command.

If you have any doubts or queries related to SQL, get them clarified from SQL experts on our SQL
Community!

42. What is the main difference between MySQL and PostgreSQL?

The basic difference between MySQL and PostgreSQL are:

My SQL is purely a relational database whereas PostgreSQL is an object-relational database. PostgreSQL is


more complex and slower than MySQL. In MYSQL, troubleshooting is easy but it is difficult to troubleshoot
PostgreSQL. MySQL does not support materialized view whereas PostgreSQL support materialized view.

You might also like