Month: June 2012

MySQL: Duplicate a column/field

You may need to duplicate an existing column/field in a MySQL table with the exact same values in the new column/field as you have in the current or original column/field. First, you’ll create a new column to the table as needed: ALTER TABLE `tablename` ADD `column2` TEXT NOT NULL; Then you’ll simply execute an UPDATE query to duplicate/copy the column over to the new column: UPDATE `table` SET `column2` = `column1`; And that’s it, you’ve duplicated your column/field in your MySQL table! You can update a MySQL field/column values with the values of multiple other MySQL fields/columns as well. For example, say you have a ‘full_name’ table field which is empty and you want to set this ‘full_name’ field value for each record to it’s ‘first_name’ and ‘last_name’ fields concatenated to form a full name, you can use MySQL CONCAT() function. UPDATE `table` SET `full_name` = CONCAT(`first_name`, ' ', `last_name`); The second parameter in the CONCAT() function above is just to create a space between the first and last...

Read More

Linux: Check inode usage in folders

Inodes are temporarily files stored on your server which are currently in use and not closed. They could be cache, temporary files or anything related and could be created in several different ways. Your server most likely has an inode usage quota (especially on VPS and shared hosting accounts) and if you exceed this it has a very similar effect to exceeding your actual disk space or random access memory (ram). The server locks up and services start failing one by one in a random fashion. Below is a command to see the directories with the highest to lowest inode usage on your server, in the current directory. Doing this in your server root might take very long so best is to CD into the folder/directory where you expect the high inode usage might be and then execute this command: find -maxdepth 1 -mindepth 1 -type d |while read dir ; do echo -n "$dir - " ; find "$dir" |wc -l; done|sed 's|^./||'|column -t|sort -rnk3|head -n10 You can also get this from the raw paste data on Pastebin: Once you see which folders/directories have the highest inode usage, you can cd into them until you find the folder with the actual problem. It could be a cache folder or a folder storing temporary images or something...

Read More

Stay up to date

Get one email per month with latest news. You can unsubscribe at any time


"; -->

Pin It on Pinterest

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!