Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Friday, May 1, 2009

Backup/RestoreMySQL thru command

Below are mysqldump commands for backup and restore mysql database:

WINDOWS:
Backup:
C:\mysql\bin> mysqldump --opt --user=username --password database > dumbfile.sql

Restore:
C:\mysql\bin>mysql --user=username --password database < dumpfile.sql


UNIX / LINUX (never try this before...)
Backup:
mysqldump --opt --user=username --password database > dumbfile.sql

Restore:
mysqldump --opt --user=username --password database < dumbfile.sql

Notes:
- dumbfile.sql contains SQL command for creating tables and data. (CREATE,INSERT,DROP etc.)

Wednesday, March 11, 2009

Oracle NVL Function

NVL function substitutes a value when a null value is encoutered.

SyntaxNVL( string1, replace_with )
string1the string to test for a null value
replace_withthe value returned if string1 is null

Applies to: Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

Example #1:

select NVL(supplier_city, 'n/a')
from suppliers;


The SQL statement above would return 'n/a' if the supplier_city field contained a null value. Otherwise, it would return the supplier_city value.

Example #2:

select supplier_id,
NVL(supplier_desc, supplier_name)
from suppliers;

This SQL statement would return the supplier_name field if the supplier_desc contained a null value. Otherwise, it would return the supplier_desc.