Visit Our UNIX and Linux User Community


Two databases


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Two databases
# 1  
Old 07-26-2011
Question Two databases

Hello,

I have two databases one is student_Name and another is student_Name1...Two tabled contain 200 records each..I found that near 30 names are entered in both databases..I would like to remove the duplicates..and i have to keep the name which is newly added..Please hepl how to remove duplicates with shell

Thank u.
# 2  
Old 07-26-2011
Code:
 
DELETE student_Name1 WHERE name IN (SELECT name FROM student_Name)

# 3  
Old 07-27-2011
Two databases

Thank you.

In my databases i have the same table with same column
EX : First database
i have a table Employee with column empname
second database : also i have the same table Employee with same column empname

I need compare this two tables of the column empname

Please get me the solution..

Thanks,
# 4  
Old 07-27-2011
Hello Anjali,

First of it's Data Base related topic and not sure why you posted here.

However,

Assuming that you are using Oracle as Data Base.

In order to access two "same" tables created in two different schemas, you have to have grant privilges. Assuming all are in place:

This will give you the common "rows" from two tables:

Code:
 
select empname from Employee where empname in (select empname from schema2.Employee)

This will give you the rows present in Schema1 Employee table but not in Schema2:

Code:
 
select empname from Employee where empname not in (select empname from schema2.Employee)

Read Oracle Documents for more information on this.
# 5  
Old 07-27-2011
Code:
select * from 1.employee
minus 
select * from 2.employee

# 6  
Old 07-27-2011
Quote:
Originally Posted by itkamaraj
Code:
select * from 1.employee
minus 
select * from 2.employee

What kind of SQL syntax is 'minus' ?

Anjali, you're probably looking for a JOIN between the tables.

To answer your question as to the same column name being in both tables, you have to fully qualify each column if their names are shared (actually, it's a good idea to fully qualify with the abbreviated name at this point).

So, if you had two tables, such as Student and Student_Grades, both which had a Student_ID column, you would qualify it as Student.Student_ID and Student_Grades.Student_ID.

The wikipedia article that I linked has a good example of JOINs and the qualified naming that you have to do (in their example, it's an employee and their department).
# 7  
Old 07-27-2011

Previous Thread | Next Thread
Test Your Knowledge in Computers #983
Difficulty: Medium
The first official NetBSD release, NetBSD 0.1, was made on 9 April 1991.
True or False?

9 More Discussions You Might Find Interesting

1. Programming

MySQL Databases

Hello all again, How do you guys backup your MySQL databases? I have a few programs that have an default back up that make an .sql file which is great but I also use OpenX which runs on PHP and has a database. That does not have an auto-back-up feature so do I just download the... (2 Replies)
Discussion started by: AimyThomas
2 Replies

2. Shell Programming and Scripting

Need help in backing up of databases.

Hi Everyone, I am new to DBA stuff. I wonder if anyone can help me. Task is that, I have 10 databases and need to take backups of all the databases using data pump in Unix/Linux, compress them using gzip and use cron to schedule the job twice a day. Appreciate if anyone can help me in... (1 Reply)
Discussion started by: sreepriya0987
1 Replies

3. UNIX for Dummies Questions & Answers

Diff command with databases

How can we compare query results from different databases using Unix diff command from command-line in Ab Initio tool? (1 Reply)
Discussion started by: eshalife
1 Replies

4. Solaris

SVM - there are no existing databases.

I am facing problems with SVM installed on vmware workstation on intel platform. I have created replicas and a mirror volume using unmountable slices. But when I reboot my hardware I am not able to execute any SVM cmd's getting an error "there are no existing databases." Below are o/p's of few... (0 Replies)
Discussion started by: rahul_11d
0 Replies

5. Web Development

Deleting databases in MYSQL problem asking...

Hi, I'm the new user of mysql. I facing one problem to delete one of the database in mysql. Hope can get all of your suggestion and advice. Input: mysql> show databases; +-------------------------+ | Database | +-------------------------+ | information_schema | |... (3 Replies)
Discussion started by: patrick87
3 Replies

6. UNIX for Dummies Questions & Answers

Checking which databases are installed

I want to check which databases are installed on my FreeBSD installation. This is what I did: pkg_info | grep mysql How do I check all in one go whether also sqlite, postgresql, firebird is installed? Thanks in advance (3 Replies)
Discussion started by: figaro
3 Replies

7. Cybersecurity

Security Databases are corrupt. HELP!!

Help! SCO Unix 5.05. A relatievely new system went down on me today. I got the dreaded error: Out of Space on Device (1/42). I was able to clear up some space in the /tmp directory, however, when I try to boot, the system prompts me to go into single user mode and I get the... (2 Replies)
Discussion started by: gseyforth
2 Replies

8. UNIX for Dummies Questions & Answers

Unix and databases

I had a person ask me if a Sql database can be run with Unix? I don't know can this be done? They only have Sql dba's and no oracle dba but want to use a Unix box???? (1 Reply)
Discussion started by: tyranunn
1 Replies

9. UNIX for Dummies Questions & Answers

ASP and Databases on UNIX?

I have been asked to use ASP on UNIX and I have no idea what the limitations are. I have pages using ASP on NT with SQL7, is there an easy transition for my current pages to work on UNIX? Any help is much appreciated. THX (5 Replies)
Discussion started by: dkropolis
5 Replies

Featured Tech Videos