August 22, 2009

Joins in Mysql

Joins in Mysql,

INNER JOIN - only rows satisfying selection criteria from both joined tables are selected.

LEFT OUTER JOIN - rows satisfying selection criteria from both joined tables are selected as well as all remaining rows from left joined table are being kept along with Nulls instead of actual right joined table values.

RIGHT OUTER JOIN - rows satisfying selection criteria from both joined tables are selected as well as all remaining rows from right joined table are being kept along with Nulls instead of actual left joined table values.

FULL OUTER JOIN - rows satisfying selection criteria from both joined tables are selected as well as all remaining rows both from left joined table and right joined table are being kept along with Nulls instead of values from other table.


Reference : http://www.gplivna.eu/papers/sql_join_types.htm

August 07, 2009

What is difference between TRUNCATE & DELETE in Mysql?

TRUNCATE is a DDL command and cannot be rolled back. All of the memory space is released back to the server.
DELETE is a DML command and can be rolled back.

Both commands accomplish identical tasks (removing all data from a table), but TRUNCATE is much faster.

TRUNCATE : You can't use WHERE clause
DELETE : You can use WHERE clause