Sponsored Content
Full Discussion: SQL compare database
Top Forums Shell Programming and Scripting SQL compare database Post 302906464 by siya@ on Thursday 19th of June 2014 11:40:02 PM
Old 06-20-2014
SQL compare database

Hi ,

I have 2 databases which has same table names and I need to list entries of a particular table in database1 not existing in the same tablename of database2.


eg : I have db1 having table name orders

Code:
 ad_d | code  | start    | end      | amountscore | id    | amount_class |
+--------+--------+----------+----------+----------+--------------+--------------+
|      1 | ww      |   935002 |   935100 |      245 | Ath | boeing         |
|      1 | e      |  4406486 |  4406628 |      575 | Lth | boeing         |
|      1 | r      | 30313484 | 30313585 |      348 | SSU | boeing         |
|      18 | f      | 44787276 | 44787468 |     1338 | SSU | boeing         |
|      1 | g     | 44787462 | 44787856 |     2775 | Ath | target         |
|      1 | m      | 44787855 | 44787944 |      747 | Ath | boeing         |
|      1 | n      | 53636773 | 53636856 |      549 | SSU | target         |
|      1 | m      | 53888147 | 53888282 |      695 | SSU | genev         |
|      1 | q      | 53888312 | 53888394 |      399 | Ath | boeing         |
|      1 | c      | 53888396 | 53888428 |      251 | Ath | geneva         |
|      1 | f      | 53888461 | 53888589 |      583 | gth | geneva


I only want to list those entries from table name orders in database 1 not present in same table name (orders) in database 2 .
The only condition is I only want to list those entries whose amount_class ='boeing'

Therefore I am interested in those entries having amount_class = "boeing" in table amount_class of DB1 not present in same table name in DB2


I tried

Code:
select * 
from (
      select *
      from DB1.orders
      except
      select *
      from DB2.orders
     ) as amountclass
Where amount_class ='Boeing';

Am I missing something?
Moderator's Comments:
Mod Comment Please use CODE tags for sample input and output as well as for sample code.

Last edited by Don Cragun; 06-23-2014 at 01:39 AM.. Reason: Add CODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Read SQL database from Unix...

Hi there, I am new here and looking for a bit of help... I don't don't know much about Unix but I've tried to include as much info as possible. We currently operate our system as a bespoke on SCO 5.05 with Informix databases. This includes a financials package called "Multisoft". Both... (0 Replies)
Discussion started by: uptheposh
0 Replies

2. AIX

Install MySQL connector without local SQL database

Hello UNIX gurus, I need to install the mysql odbc connector with unixODBC on my AIX 5.3 machine. I have a mySQL database running on another server (Ubuntu 7.04). The SQL database works fine. The problem I am having is when trying to run ./configure for mysql-connector-odbc it seems to be looking... (1 Reply)
Discussion started by: raidzero
1 Replies

3. Shell Programming and Scripting

Connecting to MS SQL database from bash (using unixODBC)

I've installed unixODBC and I would like to connect to a MS SQL (2005) database from a bash script. Can you post a code example? Thank you! :D J. (0 Replies)
Discussion started by: ph0enix
0 Replies

4. Shell Programming and Scripting

Different way to connect to database ans execute sql query

Hi Friends, I am using AIX version and sqlplus to connect to database while writing a shell script. I have implemented three ways to connect to database : 1) sqlplus -s <USERNAME>/<PASSWORD> <<! @<SQL FILE TO EXECUTE> exit ! 2) sqlplus -s <USERNAME>/<PASSWORD> <<! -----sql statemenets... (6 Replies)
Discussion started by: gauravgarg
6 Replies

5. Programming

SQL for flat file database

I have a B+ tree flat file database which is used by the application we use. I would like to implement a SQL kind of access for that DB. I have implemented my data structures to parse and store the user written query for execution. But i would like to know, do we have any standard data... (2 Replies)
Discussion started by: kumaran_5555
2 Replies

6. UNIX for Dummies Questions & Answers

shell/sql to get difference between two database

I have two queries query1 select IDW_SITE_NAME REGION,a.location_sid,a.CALENDAR_SID,count(*) from idw.vod_stream a, IDW_REF_DATA b where a.location_sid = b.location_sid and a.calendar_sid between 20110901 and 20110915 --this is start date parameter and end date parameter and... (5 Replies)
Discussion started by: qutesanju
5 Replies

7. Shell Programming and Scripting

SQL in LINUX. Variable or Database

Dear Friends :-), Need your help once again. I have following SQL in a shell script to pick values from database select date_stamp, time_stamp from logs where date=31012012 However, at times we need to take these value(s) from a variable. To do this we have following query. select... (2 Replies)
Discussion started by: anushree.a
2 Replies

8. Programming

pls. help with SQL database...

On the Linux systems, we have scripts which monitor disk usage. I want to take that data and feed that into SQL database. Can you give some advise. For example here is one of the file. I have many files like this but the format is same... 2012-09-24 04:36:14 2012-09-24 04:36:16 48414984... (3 Replies)
Discussion started by: samnyc
3 Replies

9. Programming

Dynamically checking rules in database tables using SQL

I want to check for rows in a table where all values (except the key) is empty. I am using MySQL 5.5. I plan to do this mechanically, so the approach should work for any table in my database schema. Suppose for illustration purposes I start with the following table: CREATE TABLE `sources` ( ... (4 Replies)
Discussion started by: figaro
4 Replies

10. AIX

Connect to database server and execute sql

I have a requirement and below is the detail. Create a shell script and needs to run in server "a". Connect to teradata database server "b". execute the .sql file from server "a" Save the output of the query to a file in server "a" Schedule this shell script to run every day for every 4... (1 Reply)
Discussion started by: MadhuSeven
1 Replies
devswmgr(8)						      System Manager's Manual						       devswmgr(8)

NAME
devswmgr - utility to manage the device switch database SYNOPSIS
/sbin/devswmgr [-option [parameter]] OPTIONS
Displays the following information about the device switch database: Whether a device switch database was read from the primary file or from a backup file The number of entries that are in the device switch table Displays the major numbers that have been reserved by all drivers, a named driver, or an instance of a named driver. A driver that requires more than one entry in the device switch table uses a unique instance number to reference each of its device switch table entries. Displays help for the devswmgr command. Releases all the major numbers for a device driver if just the driver name is specified. Releases one major number for a device driver if the NAME and the INSTANCENUM of the driver are speci- fied. DESCRIPTION
The devswmgr command helps you manage the device switch table by displaying information about the devices drivers in the table. You can also use the command to release device switch table entries. Typically, you release the entries for a driver after you have unloaded the driver and do not plan to reload it later. Releasing the entries frees them for use by other device drivers. EXAMPLES
The following example shows that a device switch table was loaded from the primary device and that there are 70 entries in it: % /sbin/devswmgr -display Device switch information device switch database read from primary file device switch table has 70 entries The following example shows the major numbers in the device switch table that have been reserved for the driver named cam_disk: % /sbin/devswmgr -getnum driver=cam_disk Device switch reservation list (*=entry in use) driver name instance major ------------------------------- -------- ----- cam_disk 1 8* FILES
The file that manages the device switch databases The primary device switch database file The backup device switch database file SEE ALSO
Commands: scsimgr(8) devswmgr(8)
All times are GMT -4. The time now is 11:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy