* You are viewing Posts Tagged ‘MySql’

PHP MySql fetch_assoc Vs fetch_array Vs fetch_object performance difference

In this post we will see how these 3 main MySql data fetching methods in PHP performance.

In almost all php-mysql programming, you will need to fetch data from database to populate your applications with data.

There are 3 most popular methods of getting more than one data set when fetched.

mysql_fetch_assoc() : This function fetch an associative array of data.
mysql_fetch_array() : This function returns a combination array of associative elements as well as data with numerical index.
mysql_fetch_object() : This function returns an object with properties that correspond to the fetched row.

Each data set contains a unique id element, int & a … Continue Reading

MySQL 5.6 was released as GA today

MySQL 5.6 was released as GA today. Congratulations to the team at Oracle!


There are lots of long desired features in 5.6, including global transaction ids, multi-threaded slaves, and more.

We are still using MySQL 5.1, but are working on porting our patch-set to MySQL 5.6. We are also starting to file bugs on the features we are testing for 5.6:


What’s the Maximum Length For MySQL TEXT Field Types

MySQL engine supports 4 TEXT field types


MyISAM tables in MySQL have a maximum size of a row of 65,535 bytes, so all the data in a row must fit within this limit.
However, the TEXT types are stored outside the table itself and only contribute 1 to 4 bytes towards this limit.

TEXT data types are also able to store much more data than VARCHAR and CHAR text types so TEXT types are what you need to use when storing web page or similar content in a database.

The maximum amount of data that can be stored in each data type is as … Continue Reading

MySql Interview Questions Part-II

How do you start and stop MySQL on Windows? – net start MySQL, net stop MySQL
How do you start MySQL on Linux? – /etc/init.d/mysql start
Explain the difference between mysql and mysqli interfaces in PHP? – mysqli is the object-oriented version of mysql library functions.
What’s the default port for MySQL Server? – 3306
What does tee command do in MySQL? – tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command notee.
Can you save your connection settings to a conf file? – Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, … Continue Reading

MySql Interview Questions Part-I

Q:1 How can we take a backup of a MySQL table and how can we restore it. ?
A:1 To backup:
BACKUP TABLE tbl_name[,tbl_name…] TO ‘/path/to/backup/directory’
RESTORE TABLE tbl_name[,tbl_name…] FROM ‘/path/to/backup/directory’
mysqldump: Dumping Table Structure and DataUtility to dump a database or a collection of database for backup or for transferring the data to another SQL server (not necessarily a MySQL server). The dump will contain SQL statements to create the table and/or populate the table.
-t, –no-create-info
Don’t write table creation information (the CREATE TABLE statement).
-d, –no-data
Don’t write any row information for the table. This is very useful if you just want to get a … Continue Reading

What are the different tables(Engine) present in MySQL, which one is default?

Following tables (Storage Engine) we can create:
1. MyISAM(The default storage engine IN MYSQL Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension. )
2. InnoDB(InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.)
3. Merge
4. Heap (MEMORY)(The MEMORY storage engine creates tables with contents that are stored … Continue Reading