Posts

Showing posts with the label Database

Mysql backup and restore

This tutorial explains the how to backup and restore the MySQL Database. Databases are used to store large amount of precious data and it becomes very important to Backup your data. In case case of some hardware or software failures  backup data can be used to restore the Database. Backing Up MySQL Database MySQL database backup can be accomplished in two ways: a) Copying the raw mysql database files & b) Exporting tables to text files Copying the MySQL database files MySQL uses the same table format on different platforms, so it's possible to copy MySQL table and index files from one platform and use them on another without any difficulties (assuming, of course, that you're using the same version of MySQL on both platforms). Exporting tables to text files The MySQLDump is handy utility that can be used to quickly backup th...

sqlite3 installation in Ruby On Rails

I'm having issues installing the sqlite3-ruby gem on crunchbang linux. After googling the past few hours and following several people with the same problem, I still haven't gotten it to work. Here is what I see after trying a 'sudo gem install sqlite3-ruby' Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb checking for sqlite3.h... yes checking for sqlite3_libversion_number() in -lsqlite3... yes checking for rb_proc_arity()... no checking for sqlite3_initialize()... no sqlite3-ruby only supports sqlite3 versions 3.6.16+, please upgrade! * extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Steps To follow Next I ran across this page; http://groups.google.com/group/sqlite3-ruby/brows...

alter command in mysql how to use

MySQL ALTER command is very useful when you want to change a name of your table, any table field or if you want to add or delete an existing column in a table. Lets begin with creation of a table called testalter_tbl root@host# mysql -u root -p password; Enter password:******* mysql> use TUTORIALS; Database changed mysql> create table testalter_tbl     -> (     -> i INT,     -> c CHAR(1)     -> ); Query OK, 0 rows affected (0.05 sec) mysql> SHOW COLUMNS FROM testalter_tbl; +-------+---------+------+-----+---------+-------+ | Field | Type    | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | i     | int(11) | YES  |     | NULL    |       | | c     | char(1) | YES...

inserting multiple values in table at a time

What is the optimal way to insert multiple rows (around 1000) from a web application into a table? The user enters multiple lines into a text box (up to 10,000). The ASP.NET application breaks that data into a string array. Each line is an item of that array. The user clicks Submit. I want to insert all those lines into a table in SQL Server. I know that with MySQL 4.00 and newer, I can simply issue the following command: INSERT INTO Table1 (field1) VALUES ('apple'), ('pear'), ('soda'), ('drink') This will very quickly insert all those values into Table1.field1. I know that in SQL Server, I can use a BULK INSERT from a file or BCP. However, I need to do the insert from a web application. It is better to create one large SqlCommand with all the insert statements: INSERT Table1 (field1) VALUES ('apple'); INSERT Table1 (field1) VALUES ('pear'); INSERT Table1 (field1) VALUES ('fruit'); INSERT Table1 (field...

mysql jdbc connection code

package com.test; import java.sql.*;   public class MysqlConnect{   public static void main(String[] args) throws Exception {     System. out .println( "MySQL Connect Example." );     Connection conn = null ;     String url = "jdbc:mysql://localhost:3306/" ;     String dbName = "test" ;     String driver = "com.mysql.jdbc.Driver" ;     String userName = "fff" ;     String password = "bbb" ;     try {       Class. forName (driver).newInstance();       conn = DriverManager. getConnection (url+dbName,userName,password);       System. out .println( "Connected to the database" );       conn.close();       System. out .println( ...