Archive for April, 2008

Repair the corrupted table in MySQL

Sunday, April 6th, 2008

Sometimes, high load on the server, multiple INSERTs and UPDATEs, many SELECT query execution, or hardware failure, your database server may corrupt a table. The corrupted table can be repaired back using the following statement: REPAIR TABLE tablename;

Create or copy an existing MySQL table to a new table

Sunday, April 6th, 2008

You can create a new table that looks like another table. That is newly created table will have same structure and definition as of an existing table. The definitions that are copied are: Column names, Data type, precision, length, and scale, Column text. CREATE TABLE Employee1 LIKE Employee; Above statement creates the ...

Pagination using LIMIT clause in MySQL

Sunday, April 6th, 2008

MySQL supports a really cool feature for pagination is LIMIT clause. The LIMIT clause is used to limit the number of results or rows returned in a SQL statement. So if you have 500 rows in a table, and only want to return the first 20, you would do something like ...