Archive for the ‘ MySql Interview Questions ’ Category

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 …

SELECT CURDATE(); CURRENT_DATE() = CURDATE() for time use SELECT CURTIME(); CURRENT_TIME() = CURTIME()

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.

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:

SELECT DATEDIFF(’2007-03-07′,’2005-01-01′);

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

MySQL set can take zero or more values but at the maximum it can

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 …