mysql Archives - 7-Views
MySQL – UPDATE query with LIMIT
Many a times there are certain conditions where ou want to update your records with certain limit attached to it. To update multiple rows using limit in MySQL can be implement by a query: UPDATE table_name SET field=’1′ WHERE id IN (SELECT id FROM (SELECT id FROM table_name LIMIT 0, 10) tmp);
Defragment to Recover Space in MYSQL
If our application is performing a lot of update delete operations on a certain table then there is high possibility that it contains fragmented space. The OPTIMIZE TABLE statement allows MySQL DBAs to reorganize physical table storage in order to achieve three main goals: Shrinks the data pages Shrinks index pages Computes Fresh Index Statistics […]
Insert into a MySQL table or update if exists
I we want to add a row to a database table, but if a row exists with the same unique key we want to update the row. For example Let’s say the unique key is employee_id, and in my database there is a row with employee_id=1 , In that case we want to update that […]
Row Level Locking in MySql
We need row level locking to handle the concurrent or simultaneous requests in proper way. MyISAM does not supports row level locking. Why we need row level locking? Suppose two bank clerks attempting to update the same bank account for two different transactions. Clerks 1 and 2 both retrieve (i.e., copy) the account’s record. Clerk […]