Logo F2FInterview

MySql Interview Questions

Q   |   QA

ORDER BY [col1],[col2],...,[coln]; Tels DBMS according to what columns it should sort the result. If two rows will hawe the same value in col1 it will try to sort them according to col2 and so on.GROUP BY [col1],[col2],...,[coln]; Tels DBMS to group results with same value of column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if you want to count all items in group, sum all values or view average

Set char to occupy n bytes and it will take n bytes even if u r
storing a value of n-m bytes Set varchar to occupy n bytes and it will take only the required space
and will not use the n bytes
eg. name char(15) will waste 5 bytes if we store ‘romharshan’, if each char takes a byte
eg. name varchar(15) will just use 10 bytes if we store ‘romharshan’, if each char takes a byte. rest 5 bytes will be free.

you can use LOAD DATA INFILE file_name; syntax to load data
from a text file. but you have to make sure that
a) data is delimited
b) columns and data matched correctly

SELECT DATEDIFF(“2007-03-07″,”2005-01-01″);

To backup: BACKUP TABLE tbl_name[,tbl_name] TO ‘/path/to/backup/directory’
RESTORE TABLE tbl_name[,tbl_name] FROM ‘/path/to/backup/directory’mysqldump: Dumping Table Structure and DataUtility to dump a database or a collection of database for backup or for transferring the data to another SQL server (not necessarily a MySQL server). The dump will contain SQL statements to create the table and/or populate the table.
-t, no-create-info. Don’t write table creation information (the CREATE TABLE statement).
-d, no-data. Don’t write any row information for the table. This is very useful if you just want to get a dump of the structure for a table!

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: