Here I shall be jotting down one by one simple SQL commands that we use .
Check the comments .

Here I shall be jotting down one by one simple SQL commands that we use .
Check the comments .

From a long time we have been using “yaml_db” as a plugin for taking backups of DB .
Obviously, lots of people will say when a simple rake command and a sql command can do the same then why a plugin/gem , but when theres a bread already baked then concentrate on the curry why think about baking a new one .
Anyways , the following are some steps .
Source : http://www.railslodge.com/plugins/830-yaml-db
1. ruby script/plugin install git://github.com/adamwiggins/yaml_db.git 2. rake db:data:dump -> Dump contents of Rails database to db/data.yml rake db:data:load -> Load contents of db/data.yml into the database
From the readme
= YamlDb
YamlDb is a database-independent format for dumping and restoring data. It complements the the database-independent schema format found in db/schema.rb. The data is saved into db/data.yml.
This can be used as a replacement for mysqldump or pg_dump, but only for the databases typically used by Rails apps. Users, permissions, schemas, triggers, and other advanced database features are not supported – by design.
Any database that has an ActiveRecord adapter should work.
== Usage
rake db:data:dump -> Dump contents of Rails database to db/data.yml rake db:data:load -> Load contents of db/data.yml into the database
Further, there are tasks db:dump and db:load which do the entire database (the equivalent of running db:schema:dump followed by db:data:load).
== Examples
One common use would be to switch your data from one database backend to another. For example, let’s say you wanted to switch from SQLite to MySQL. You might execute the following steps:
1. rake db:dump 2. Edit config/database.yml and change your adapter to mysql, set up database params 3. mysqladmin create [database name] 4. rake db:load
Although ActiveRecord has the following warning about database specific column types: “You may use a type not in this list as long as it is supported by your database (for example, “polygon” in MySQL), but this will not be database agnostic and should usually be avoided. ActiveRecord” You may have optimizations specific to a database server like MySql’s varbinary. Here is how to create the a table with a varbinary(1000) column.
create_table :page_error_sources do |t| t.column :source, 'varbinary(1000)', :null => false t.timestamps end
Reference : MSQL VarBinary