Archive for the ‘MySql Interview Questions’ Category
How can I retrieve values from one database server and store them in other database server using PHP?
Wednesday, March 3, 2010 11:04 No CommentsWe can always fetch from one database and rewrite to another. Here is a very simple solution.
$db1 = mysql_connect("hostname","username","password") // Connect to Server 1
mysql_select_db("db1″, $db1);
$res1 = mysql_query("query",$db1);
$db2 = mysql_connect("hostname","username","password"); // Connect to Server 2
mysql_select_db("db2″, $db2);
$res2 = mysql_query("query",$db2);
At this point you can only fetch [...]
Explain the difference between FLOAT, DOUBLE and REAL
Tuesday, March 2, 2010 17:33 1 CommentFLOATs store floating point numbers with 8 place accuracy and take up 4 bytes.
DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes.
REAL is a synonym of FLOAT for now.
What is meant by Persistent Database Connection?
Tuesday, February 23, 2010 13:14 No CommentsPersistent connections are links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there’s already an identical persistent connection (that remained open from earlier) – and if it exists, it uses it. If it does not exist, it creates the link. An ‘identical’ connection [...]
UK Postcodes Complete Database Table – Import and Enjoy
Friday, February 19, 2010 11:43 No Comments1. Download this file and import it into your database. Postcodes.txt
2. Rename Postcode.txt to Postcode.sql
3. Import to your database and enjoy complete list of UK Postcodes.
Here is the sample code:
CREATE TABLE IF NOT EXISTS `postcodes` (
`id` int(11) NOT NULL auto_increment,
`postcode` tinytext NOT NULL,
`grid_n` varchar(15) NOT NULL,
`grid_e` varchar(15) [...]
How to connect to MySQL database using PHP?
Wednesday, February 17, 2010 10:36 1 Comment<?php
$username = "your_name";
$password = "your password";
$hostname = "localhost";
$dbname = "database name";
//Connection to the MySql Database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
mysql_select_db("$dbname",$db);
echo "Connected to MySQL";
?>
What is the difference between mysql_connect() and mysql_pconnect()?
Tuesday, February 16, 2010 11:19 No CommentsWhen they are using mysql_connect() function, every time it is opening and closing the database connection, depending on the request .
mysql_connect() and mysql_pconnect() both are working for database connection but with small difference. In mysql_pconnect(), ‘p’ stands for persistance connection.
But in case of mysql_pconnect() function,
First, when connecting, the function would try to find a (persistent) [...]
MySQL Optimization
Thursday, February 4, 2010 23:48 No Commentsmyisamchk is used to get information about your database tables or to check, repair, or optimize them. This command can check or repair MyISAM tables. It can also optimize and analyze these tables. Database design, tuning of databases can be used to improve and optimize performance of MySql.
Indexes should be used to [...]
What is the default table in MYSQL?
Wednesday, December 16, 2009 22:58 No CommentsWhat is the default table in MYSQL and which type of table is generatedby default.
MyISAM is the default storage engine.
What is maximum size of a database in MySQL?
Wednesday, December 2, 2009 17:52 No CommentsIf the operating system or filesystem places a limit on the number of files in a directory, MySQL is bound by that constraint.The efficiency of the operating system in handling large numbers of files in a directory can place a practical limit on the number of tables in a database. If the time required to [...]
Please explain .frm .myd .myi in mysql?
Monday, November 2, 2009 17:49 No CommentsEach 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.
The ‘.frm’ file stores the table definition.
The data file has a ‘.MYD’ (MYData) extension.
The index file has a ‘.MYI’ (MYIndex) extension.


