InnoDB vs MyISAM
Set the DB to InnoDB instead of MyISAM MYISAM: MYISAM supports Table-level Locking MyISAM designed for need of speed MyISAM does not support foreign keys hence we call MySQL with MYISAM is DBMS MyISAM...
View ArticleSimple yet useful SQL statement
Mostly for MySQL To duplicate a table: CREATE TABLE new_table LIKE old_table; To replace some character in a field value: update TABLENAME set FIELDNAME = replace (FIELDNAME, searchstr, replacestr)
View ArticleImport csv and create table at once on sequel pro
If you have a csv file, you can easily import the csv and create a table in mysql using Sequel Pro. As usual, choose File > Import Choose a csv file And click on the “New” button to create a new...
View ArticleCopy table to a different database
CREATE TABLE `db1.table1` SELECT * FROM `db2.table1`;
View ArticleAppend 0’s in MySQL
In MySQL there is function to append character to string. LPAD for left padding LPAD(str,len,padstr) RPAD for right padding Example of usage 1 2 3 UPDATE sometable SET FIELD = LPAD (FIELD,'5','00')...
View ArticleWays to auto backup MySQL database
1. AutoMySQLBackup AutoMySQLBackup with a basic configuration will create Daily, Weekly and Monthly backups of one or more of your MySQL databases from one or more of your MySQL servers. Other Features...
View ArticleLedger – debit and credit
Here’s the list Debit Credit Collection x Bill x CN x DN x Refund x
View ArticleUse decimal, not float for money value
Use decimal at it is more accurate for money value in MySQL. e.g. rounding etc. Using float will end up some inaccuracy of calculation.
View ArticleGetting data from CI db query
1. All result set $query = $this->db->query("YOUR QUERY"); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { echo $row->title; echo $row->name;...
View ArticleSample use of CI query builder for CRUD
Sample insert $data = array( 'title' => $title, 'name' => $name, 'date' => $date ); $this->db->insert('mytable', $data); Sample update $this->db->update('mytable', $data, "id =...
View ArticleSome uncommon mysql command
https://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_coalesce COALESCE() IN NOT_IN NOT_LIKE
View ArticleTransparent Data Encryption (TDE)
To secure the data by encryption at data at database level. This will be full done by database application and won’t affect the application level. Almost all popular RDBMS provide this feature but...
View ArticleNotes on Azure
Some notes on Microsoft Azure 3 type of services provided App Service – Scalable Web Apps, Mobile Apps, API Apps, and Logic Apps for any device Cloud Service – Highly available, scalable n-tier cloud...
View ArticleCheck value exist in a table but not in another table
SQL to check a value exist in one table but not in another. SELECT t1.name FROM table1 t1 LEFT JOIN table2 t2 ON t2.name = t1.name WHERE t2.name IS NULL or this (not tested) SELECT * FROM B WHERE NOT...
View ArticleMySQL transaction
Transaction feature suitable to be used in 2 conditions. If you have multiple statements to run and want to ensure all of them run successfully to conclude the task. If you want to run a delete...
View Article