-
MySQL Dump and Reload
This one has been on my draft for more than a year already so I better fix it up and share. Besides, I find myself more and more googling my site to find my posts instead of searching via the WP admin. Without further ado, here it is..
-
Date Functions in MySQL
Here’s few of the usual equivalent Oracle data functions in MySQL. DATE ADD (SYSDATE +/-1) SELECT DATE_ADD(SYSDATE(),INTERVAL 1 DAY); SELECT DATE_ADD(SYSDATE(),INTERVAL -10 DAY);
-
Oracle NVL Equivalent in MySQL
Here’s the MySQL equivalent of Oracle’s NVL and MSSQL/Sybase’s ISNULL functions. Syntax IFNULL(expr1,expr2) Usage If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2. Take note that IFNULL() returns a numeric or string value, depending on the context in which it is used. I haven’t used it for other data types yet but…
-
MySQL SEQUENCE Equivalent
Most Oracle guys (and I heard PostgreSQL, too) will be missing sequence in MySQL. The nearest equivalent that MySQL has for this feature is the AUTO INCREMENT field. However, auto increment is sometimes not sufficient and time will come that you will be missing it. Case in point is the alpha-numeric auto-generated code. In Oracle,…
-
MySQL Administration Commands
Backup MySQL Database into a File -bash-3.2$mysqldump -ujhondoe -p mydb_name > mydb_name_backup.sql password: -bash-3.2$ zip mydb_name_backup.zip mydb_name_backup.sql Load MySQL Backup Into Database -bash-3.2$mysql -ujhondoe mydb_name < mydb_name_backup.sql password: Create User in MySQL mysql> CREATE USER ‘jhondoe’@'localhost’ IDENTIFIED BY ‘mypassword’; mysql> GRANT ALL PRIVILEGES ON mydbname.* TO ‘jhondoe’@'localhost’ WITH GRANT OPTION; mysql> CREATE USER ‘jhondoe’@'%’ IDENTIFIED…
-
Rename Tables in MySQL
If you want to hand code renaming tables, here’s the sample. Single Table RENAME TABLE wp_users TO kwg_users; multiple tables RENAME TABLE wp_users TO kwtg_users, wp_usermeta TO kwtg_usermeta, wp_site TO kwtg_wpsite, wp_signups TO kwtg_signups; This is handy when renaming a whole lot of tables as in the case of WordPress mu where each blog has…
Recent Comments