Archive for the ‘ MySql Interview Questions ’ Category
What is the difference between Primary Key and Unique key?
on October 21, 2009
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 unique key.There can be only one primary key …
How many ways we can we find the current date using MySQL?
on October 2, 2009
SELECT CURDATE(); CURRENT_DATE() = CURDATE() for time use SELECT CURTIME(); CURRENT_TIME() = CURTIME()
Explain the difference between MyISAM Static and MyISAM Dynamic
on September 2, 2009
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 beginning of the next record.
What is the maximum length of a table name, database name, and fieldname in MySQL?
on August 3, 2009
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 identifiers:
How can we know the number of days between two given dates using MySQL?
on August 2, 2009
SELECT DATEDIFF(’2007-03-07′,’2005-01-01′);
How can I load data from a text file into a table?
on August 2, 2009
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 correctly
How many values can the SET function of MySQL take?
on July 3, 2009
MySQL set can take zero or more values but at the maximum it can
Explain the difference between BOOL, TINYINT and BIT
on July 2, 2009
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 data.
Order by vs GROUP By
on June 15, 2009
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 field.
The CHAR and VARCHAR Types
on June 15, 2009
he 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. For example, CHAR(30) can hold up to 30 …

