Thursday, October 16, 2014

Linux Interview Question and Answer - Mysql part 4

10:27 AM


1. Explain 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 data.
 
2. Explain the difference between 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 now.
 
3. If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table? 

 999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
 
4. What happens if a table has one column defined as TIMESTAMP? 

 That field gets the current timestamp whenever the row gets altered.
 
5. But what if you really want to store the timestamp data, such as the publication date of the article? 

 Create two columns of type TIMESTAMP and use the second one for your real data.
 
6. Explain data type TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP  

    The column exhibits the same behavior as a single timestamp column in a table with no other timestamp columns.

7. What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do? 

  On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
         
        8. Explain TIMESTAMP DEFAULT ‘2006:09:02 17:38:44′ ON UPDATE CURRENT_TIMESTAMP. 

 A default value is used on initialization, a current timestamp is inserted on update of the row.

 9. If I created a column with data type VARCHAR(3), what would I expect to see in MySQL table? 

CHAR(3), since MySQL automatically adjusted the data type.

Written by

0 comments :

Post a Comment

 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism