thanks for the info i went thorugh the site which you have mentioned. but they have specified only softwares to find differences. i already have a software called mysql testbench which finds me the difference in mysql dumps.. let me explain the problem i am dealing with consider there are two myssql dumps.. that is .sql(which can be compared to a txt file). out of these two .sql files one is dump of latest database and one is old database. for eg here is the format of the files
Latest mysql dump in file1.sql
-- MySQL dump 10.13 Distrib 5.1.44, for unknown-linux-gnu (x86_64)
--
-- Host: localhost Database: release_c
-- ------------------------------------------------------
-- Server version 5.1.44-enterprise-commercial-pro-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
--
-- Table structure for table `Blahblahblah`
--
use dabbDB;
DROP TABLE IF EXISTS `Blahblahblah`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Blahblahblah` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`action` enum('Change','Delete','Add','Locked','Unlocked') COLLATE utf8_unicode_ci DEFAULT 'Change',
`date` datetime DEFAULT NULL,
`reserved1` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`reserved2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`zoneId` int(11) DEFAULT NULL,
) ENGINE=InnoDB AUTO_INCREMENT=2000 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
.
.
.
.
etc etc
--------------------------------------------------------------------------
OLD mysql dump in file2.sql
-- MySQL dump 10.13 Distrib 5.1.44, for unknown-linux-gnu (x86_64)
--
-- Host: localhost Database: release_c
-- ------------------------------------------------------
-- Server version 5.1.44-enterprise-commercial-pro-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
--
-- Table structure for table `Blahblahblah`
--
use dabbDB;
DROP TABLE IF EXISTS `Blahblahblah`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Blahblahblah` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`action` enum('Change','Delete','Add','Locked','Unlocked') COLLATE utf8_unicode_ci DEFAULT 'Change',
`date` datetime DEFAULT NULL,
) ENGINE=InnoDB AUTO_INCREMENT=2000 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
.
.
.
.etc etc
=====================================
obeserve that in old mysql dump file column names such as reserved1 reserved2 are missing.. what i want to do is found out these differences and list them out and if its missing go to a function called alter_query() where it inserts this one more coulmn to the database or may be write the query to a third file which we could use to run to manually.... or if one column name is missing in new database dump but present in old then this column must be deleted hence it goes to delete_query()function.. i know it will involve lot of loops and string comparison .. i dont know how to kick start.. i just somehow comeup with freading a file and printing them.. so have to start from scratch...
#!/bin/sh
echo enter file name
read fname
exec<$fname
value=0
while read line
do
# value=`expr $value + 1`;
# the abovel ine gives the number of line in the file
echo "$line"
done
# echo "$value";
---------- Post updated 15-11-11 at 12:03 PM ---------- Previous update was 14-11-11 at 12:03 PM ----------
there is a command as
diff filename1.sql filename2.sql > output_diff_file.sql
this above code will just show differences inthe files. i need differences with respect to their tables :wall::wall::wall::wall::wall::wall::wall::wall::wall::wall: