Archive: mysql interview question
-
Sep 02, 2011
Comments OffHow to optimize mysql query and mysql database?
There is lots of way to optimize mysql. once you optimize your query and database of mysql it will make your website and application very fast. Firstly choose which table being used every time for delete, insert or update make a list and always repair these tables. after 15 days. this is very good question...
-
Aug 29, 2011
Comments OffWhat does myisamchk do?
It compressed the MyISAM tables, which reduces their disk...
-
Aug 29, 2011
Comments OffThe CHAR and VARCHAR Types
the CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved. As of MySQL 5.0.3, they also differ in maximum length and in whether trailing spaces are retained. The CHAR and VARCHAR types are declared with a length that indicates the maximum number of characters you want to store....
-
Aug 29, 2011
Comments OffOrder by vs GROUP By
The easiest explanation is that order by is doing the sorting of a table and the group by clause is used for aggregation of a...
-
Aug 29, 2011
Comments OffExplain the difference between BOOL, TINYINT and BIT
Prior to MySQL 5.0.3: those are all synonyms. After MySQL 5.0.3: BIT data type can store 8 bytes of data and should be used for binary...
-
Aug 29, 2011
Comments OffHow many values can the SET function of MySQL take?
MySQL set can take zero or more values but at the maximum it...
-
Aug 29, 2011
Comments OffHow can I load data from a text file into a table?
We can use LOAD DATA INFILE file_name; syntax to load data from a text file. but we have to make sure that a) data is delimited b) columns and data matched...
-
Aug 29, 2011
Comments Off
-
Aug 29, 2011
Comments OffWhat is the maximum length of a table name, database name, and fieldname in MySQL?
The following table describes the maximum length for each type of identifier. Database – 64 bytes Table – 64 bytes Column – 64 bytes Index – 64 bytes Alias – 255 bytes There are some restrictions on the characters that may appear in...
-
Aug 29, 2011
Comments OffExplain the difference between MyISAM Static and MyISAM Dynamic
MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the...
-
Aug 29, 2011
Comments OffHow many ways we can we find the current date using MySQL?
SELECT CURDATE(); CURRENT_DATE() = CURDATE() for time use SELECT CURTIME(); CURRENT_TIME() =...
-
Aug 29, 2011
Comments OffWhat is the difference between Primary Key and Unique key?
Primary Key: A column in a table whose values uniquely identify the rows in the table. A primary key value cannot be NULL. Unique Key: Unique Keys are used to uniquely identify each row in the table. There can be one and only one row for each unique key value. So NULL can be a...
-
Aug 29, 2011
Comments OffPlease explain .frm .myd .myi 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. The ‘.frm’ file stores the table definition. The data file has a ‘.MYD’ (MYData) extension. The index file has a ‘.MYI’ (MYIndex)...
-
Aug 29, 2011
Comments OffWhat is maximum size of a database in MySQL?
If 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...
-
Aug 29, 2011
Comments OffWhat is the default table in MYSQL?
What is the default table in MYSQL and which type of table is generatedby default. MyISAM is the default storage...
-
Aug 29, 2011
Comments Offhow to do MySQL Optimization
myisamchk 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 increase the...
-
Aug 29, 2011
Comments OffWhat Is the Difference Between Mysql_Connect() and Mysql_Pconnect()?
When 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 persistence connection. But in case of mysql_pconnect() function, first, when connecting, the function would try to...
-
Aug 29, 2011
Comments OffHow to Connect to MySQL Database Using PHP?
<?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";...
-
Aug 29, 2011
Comments OffUK Postcodes Complete Database Table – Import and Enjoy
1. 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: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 CREATE TABLE IF NOT EXISTS...
-
Aug 29, 2011
Comments OffExplain the difference Among FLOAT, DOUBLE and REAL
FLOATs 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...