SQL question (easy? hard? dunno!)
Not sure if this is really easy and I'm being dense but....
Given two tables, A & B, how (using SQL only) can I tell whether they contain identical data?
Given that it's not possible to get boolean result from SQL, I don't mind (within reason!) what format the result takes
Cheers
RT
Andrew's query does not work as expected **if there are duplicate rows in each table**. No offence to you Andrew, I am just pointing it out as the matter of the subject, read it to the end and you will see how I found out about this, I did not mean to fail your code in any way.SQL> select * from inv;
SEQ INV AMT AMT2
1 AB12 2000 702.4
2 ABC123 2000 48.6
3 1234 100 10
-- duplicate all the rows in inv table
SQL> insert into inv select * from inv;
3 rows created.
SQL> select * from inv;
SEQ INV AMT AMT2
1 AB12 2000 702.4
2 ABC123 2000 48.6
3 1234 100 10
1 AB12 2000 702.4
2 ABC123 2000 48.6
3 1234 100 10
6 rows selected.
SQL> select * from inv2;
no rows selected
-- Make both tables indentical
SQL> insert into inv2 select * from inv;
6 rows created.
SQL> SELECT decode(count(*) , 1, 'SAME', 'DIFFERENT') whatever
2 FROM ( SELECT count(*) t FROM inv
3 INTERSECT
4 SELECT count(*) FROM inv2 ) tot_rec
5 , (SELECT count(*) t FROM ( SELECT * FROM inv
6 INTERSECT
7 SELECT * FROM inv2 ) ) tot_match
8 WHERE tot_rec.t = tot_match.t
9 /
WHATEVER
DIFFERENT
-- In fact they are identical
SQL> select * from inv
2 minus
3 select * from inv2;
no rows selected
SQL> select * from inv2
2 minus
3 select * from inv;
no rows selectedFollowing version has the same problem. I am just posting it for the relevance.
In case where where we can assume that there would not be any duplicate
rows in each table, then here is another simple solution, SELECT decode(cnt1, cnt2, decode(cnt1, cnt3, 'TRUE', 'FALSE'), 'FALSE') yes_no
FROM
(select count(*) cnt1 from inv),
(select count(*) cnt2 from inv2),
(select count(*) cnt3 from (select * from inv union select * from inv2))I was thinking about duplicates problem with UNION alternative and that is when
I found out that Andrew's SQL has the same caveat.
Thx,
SriDHAR
Similar Messages
-
Question: My hard and back up disk both failed
Question: My hard and back up disk both failed on the same day, strange but the kids were on the computer and things happen.
Running Mac OS 10.6
I paid $800 to "super geeks" to recover the pics > 30,000 (many duplicates)
I will receive a 500 gig external drive from them today via Fed Ex with the pics recovered .
My plan is to move them to my iMac (had a new HD put in) but I do not want to transfer 30,000 pics prior
to running duplicate annihilator & thumbnail annihilator on the new external drive.
Is there an easy way to do this > looking for help?
Can I run the programs on the recovered drive I will receive today prior to my transferring?
Or is there a more efficient way of doing this. I have already paid for Duplicate Annilator.
Maybe there is a different app I should use?Hi Bill,
Reading about it, I'm guessing so if you use iPhoto to Import the photos off the external drive...
Easily find and annihilate duplicates created internally by iPhoto or during import.
http://brattoo.com/propaganda/ -
I can't find the orainst.exe file on Oracle's site to setup SQL & ODBC on a client machine. Does anyone know where to get this?
I'm not sure I follow your question...
SQL*Net Easy Config is a utility that allows you to do things like configure your tnsnames.ora file after you have installed the Oracle client.
The ODBC Data Source Administrator allows you to configure ODBC connections to your database after the Oracle client has been installed.
The Oracle Universal Installer allows you to install the Oracle client in the first place.
Which, if any, of these utilities are you referring to?
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
SQL Question Bank and Answers for Practise
Dear Readers:
Does any one have any recommendation on SQL question bank and answers where I could practice my SQL.
I have developed some basic knowledge of SQL thanks to the MS community, but I am looking for some additional Questions or textbook recommendations which has questions and answers to queries for practice.
Best Wishes,
SQL75Hi,
Refer below post.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/446b2247-5124-49c1-90c9-b7fea0aa4f83/sql-dba-books?forum=sqlgetstarted
Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
Praveen Dsa | MCITP - Database Administrator 2008 |
My Blog | My Page -
Sql question : TRUNCATE vs Delete
hi
this is sql question, i don't know where i should post it, so here it is.
i just want to know the best usage of each. both commands delete records in a table, one deletes all, and the other can do the same plus option to delete specified records. if i just want to purge the table. which one is better and why? thanksthis is crucial to my design, i need to be able to
rollback if one of the process in the transaction
failed, the whole transaction should rollback. if
truncate does not give me this capability, then i have
to consider Delete.From the Oracle manual (sans the pretty formatting):
TRUNCATE
Caution: You cannot roll back a TRUNCATE statement.
Purpose
Use the TRUNCATE statement to remove all rows from a table or cluster. By default,
Oracle also deallocates all space used by the removed rows except that specified by
the MINEXTENTS storage parameter and sets the NEXT storage parameter to the size
of the last extent removed from the segment by the truncation process.
Removing rows with the TRUNCATE statement can be more efficient than dropping
and re-creating a table. Dropping and re-creating a table invalidates the table?s
dependent objects, requires you to regrant object privileges on the table, and
requires you to re-create the table?s indexes, integrity constraints, and triggers and
respecify its storage parameters. Truncating has none of these effects.
See Also:
DELETE on page 16-55 and DROP TABLE on page 17-6 for
information on other ways to drop table data from the database
DROP CLUSTER on page 16-67 for information on dropping
cluster tables
Prerequisites
To truncate a table or cluster, the table or cluster must be in your schema or you
must have DROP ANY TABLE system privilege. -
Urgent SQL question : how to flip vertical row values to horizontal ?
Hello, Oracle people !
I have an urgent SQL question : (simple for you)
using SELECT statement, how to convert vertical row values to horizontal ?
For example :
(Given result-set)
MANAGER COLUMN1 COLUMN2 COLUMN3
K. Smith ......1
K. Smith ...............1
K. Smith ........................1
(Needed result-set)
MANAGER COLUMN1 COLUMN2 COLUMN3
K. Smith ......1 .......1 .......1
I know you can, just don't remeber how and can't find exactly answer I'm looking for. Probably using some analytic SQL function (CAST OVER, PARTITION BY, etc.)
Please Help !!!
Thanx !
Steve.scott@ORA92> column vice_president format a30
scott@ORA92> SELECT f.VICE_PRESIDENT, A.DAYS_5, B.DAYS_10, C.DAYS_20, D.DAYS_30, E.DAYS_40
2 FROM (select t2.*,
3 row_number () over
4 (partition by vice_president
5 order by days_5, days_10, days_20, days_30, days_40) rn
6 from t2) f,
7 (SELECT T2.*,
8 row_number () over (partition by vice_president order by days_5) RN
9 FROM T2 WHERE DAYS_5 IS NOT NULL) A,
10 (SELECT T2.*,
11 row_number () over (partition by vice_president order by days_10) RN
12 FROM T2 WHERE DAYS_10 IS NOT NULL) B,
13 (SELECT T2.*,
14 row_number () over (partition by vice_president order by days_20) RN
15 FROM T2 WHERE DAYS_20 IS NOT NULL) C,
16 (SELECT T2.*,
17 row_number () over (partition by vice_president order by days_30) RN
18 FROM T2 WHERE DAYS_30 IS NOT NULL) D,
19 (SELECT T2.*,
20 row_number () over (partition by vice_president order by days_40) RN
21 FROM T2 WHERE DAYS_40 IS NOT NULL) E
22 WHERE f.VICE_PRESIDENT = A.VICE_PRESIDENT (+)
23 AND f.VICE_PRESIDENT = B.VICE_PRESIDENT (+)
24 AND f.VICE_PRESIDENT = C.VICE_PRESIDENT (+)
25 AND f.VICE_PRESIDENT = D.VICE_PRESIDENT (+)
26 AND f.VICE_PRESIDENT = E.VICE_PRESIDENT (+)
27 AND f.RN = A.RN (+)
28 AND f.RN = B.RN (+)
29 AND f.RN = C.RN (+)
30 AND f.RN = D.RN (+)
31 AND f.RN = E.RN (+)
32 and (a.days_5 is not null
33 or b.days_10 is not null
34 or c.days_20 is not null
35 or d.days_30 is not null
36 or e.days_40 is not null)
37 /
VICE_PRESIDENT DAYS_5 DAYS_10 DAYS_20 DAYS_30 DAYS_40
Fedele Mark 35473 35209
Fedele Mark 35479 35258
Schultz Christine 35700
South John 35253
Stack Kevin 35701 35604 35402 35115
Stack Kevin 35705 35635 35415 35156
Stack Kevin 35706 35642 35472 35295
Stack Kevin 35707 35666 35477
Stack Kevin 35667 35480
Stack Kevin 35686
Unknown 35817 35698 35596 35363 35006
Unknown 35702 35597 35365 35149
Unknown 35724 35599 35370 35155
Unknown 35600 35413 35344
Unknown 35601 35451 35345
Unknown 35602 35467
Unknown 35603 35468
Unknown 35607 35475
Unknown 35643 35508
Unknown 35644
Unknown 35669
Unknown 35684
Walmsley Brian 35725 35598
23 rows selected. -
I can't connect Developer 2000 at a client site with the Database on th Server:
AFTER INSTALLING THE DEVELOPER 2000 R2.1 ON THE CLIENT MACHINE(WIN 98),
I NEED TO CONNECT HIM TO THE ORACLE DATABASE(ORACLE 8 ENTERPRISE EDITION)
ON THE SERVER(WINNT),
I DEFINED THE FOLLOWING SERVICE (DB ALIAS) ON THE ORACLE SERVER(TNSNAMES.ORA):
XXX.WORLD =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = 3.1.1.1)
(PORT = 1521)
(CONNECT_DATA = (SID = ORCL)
WHAT I DID WAS THAT I WENT TO SQL NET EASY CONFIGURATION, AT CLIENT MACHINE
AND SELECT TO ADD DATABASE ALIAS,
THEN I ENTERED THE DB ALIAS NAME: KOKO (FOR EXAMPLE)
THEN I ENTERED THE TCP\IP ADDRESS OF THE SERVER: 3.1.1.1,
THEN I ENTERED THE DATA BASE INSTANCE : ORCL,
THEN I CONFIRMED THE OPERATION AND EXIT THE SQL NET EASY CONFIGURATION.
THEN I WENT TO THE TNSNAMES.ORA FILE, AND CHECK FOR THE DEFININTION, AND IT
WAS OK. AND AS FOLLOWS:
KOKO.WORLD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = TCP.WORLD)
(PROTOCOL = TCP)
(HOST = 3.1.1.1)
(PORT = 1521)
(ADDRESS =
(COMMUNITY = TCP.WORLD)
(PROTOCOL = TCP)
(HOST = 3.1.1.1)
(PORT = 1526)
(CONNECT_DATA = (SID = ORCL)
THEN I TRYED TO CONNECT TO THE DATABASE USING SQLPLUS8 FROM THE USER MACHINE,
BUT I GET THIS ERR MSG;
ERROR:
ORA-12154: TNS:COULD NOT RESOLVE SERVICE NAME
I TRYED TO GO TO ORACLE REGISTRY FILE AND ADD A STRING LOCAL: XXX
THIS XXX IS THE NAME OF THE DATABASE ALIAS ON THE SERVER.
AFTER THAT I TRYED TO CONNECT TO THE DATABSE, AND I GOT THE SAME ERR MSG:
ERROR MSG:
ERROR:
ORA-12154: TNS:COULD NOT RESOLVE SERVICE NAME
IF YOU HAVE AN IDEA, I WILL APPRECIATE SHARING IT.
nullhi,
If you are installing D2K on '98 please insure the following:
1. does the cient machine have orawin95/98 folder?
2. In orawin95/net80/admin you said you have TNSNAMES.ORA but do you also have SQLNET.ORA with a proper configuration pointing to TNSNAMES.ORA?
Tushar -
Installing Sql net-easy configuration assistant
I had installation of Oracle 8.i Server and I have made an installation of all Oracle 8.i Client on my desktop, but it failed before installing the package for Sql net-easy configuration.
I retry to deinstall and install all Oracle package, but I was unable to reach again the same step.
How do I install the Sql net easy package, in order to get it available within the Oracles menu in the Window Start menu?
Thanks
Robertohi,
If you are installing D2K on '98 please insure the following:
1. does the cient machine have orawin95/98 folder?
2. In orawin95/net80/admin you said you have TNSNAMES.ORA but do you also have SQLNET.ORA with a proper configuration pointing to TNSNAMES.ORA?
Tushar -
One easy question, one harder
Easy: I can't figure out how to view or move a single page in my iphoto book. Each time I try to move an individual page, the whole spread goes with it. 'Help' says there is a choice on the view button to display either a spread or a single page, but I can't find that. I can only view either the spread, or the individual photos.
Harder: Like others here, I have the "incomplete book"- missing photos issue when I try to buy my book. I have tried the advice that has been written here to look for any gray pages behind any full page photo layouts. I must not be understanding this, because it seems that when I resize my full page photos to see the backgrounds, all my full page photos have gray backgrounds. I then change it to a solid background, then resize my photo back to full. Then, when I drag the photo temporarily away, it is still a gray background. It appears to just replace the solid background back with the full photo which is what I originally had. And, how or should I check this when it is a 2 photo format where one pic is the full page and the other is small and perhaps attached to text (using travel template). Moving formats, and resizing full page photos has gotten my book all mixed up which is why I need to move individual pages back around (see first question). I saw that one person had to completely layout their book again to make it work. I have already put 8 hours into the project (and another 2 with trying to figure out this mess) and don't want to have to start from scratch. I am current in all the software updates. Help!I found the culprit page where the photo was expected. Problem fixed, but it's not very intuitive at all. Apple needs to help us find our errors better.
-
EASY Question - But Hard for the Actioscript inept
Ok,
So this is my first attempt at making a web page...
I am trying to simply make my little button display my movie
labeled "Content", I don't think I am doing somthing right...
Doh....
I have diffrent movies (p1 & p2) for button rollover
effects... and I have a seperate clip named content with labels for
"start1" and "start2" that I want to display when I click the
buttons
Anywho if you would like to take a look see I would be very
thankful:
http://www.itamidesign.com/test.fla
Thanks for your help...
-ToddSomething went wrong when I tried your link.
Is your movie inside your flash program or is it an external
movie?
If you have named your button something like myBtn, then you
can put in some actionscript to load an external movie such as:
myBtn.onRelease = function():Void
movieHolder.loadMovie("content");
where movieHolder is the name of an empty movie clip that you
place on the stage to hold external movies.
Alternately, you can add the code to the button itself. In
this case you don't need to give the button an instance name:
on (release)
movieHolder.loadMovie("content");
If your movie is already part of your Flash program, instead
of an external file, then you will need to go into the linkage
properties of the movie and check: "Export for ActionScript". You
do this by right clicking on the movie in the library. You must
give the movie a name when you do this. You can still call it
"Content". Next you use one of the formats listed above except
change loadMovie to attachMovie. (Actually they might both still
work, but I have been in the habit of using loadMovie for external
content and attachMovie for internal content. Don't ask me why, I
just try things and when they work, I tend to repeat that method of
doing things.)
For attachMovie, you will need to give your clip a level
number. You can hard code in a number if you want any movie you
attach to replace the prior movie or you can use:
movieHolder.getNextHighestDepth() if you want your movie to be
placed on top of anything else that you already have in the movie
holder without replacing it.
You can type loadMovie or attachMovie in the search bar of
the built in help menu to see more examples. If you have further
questions such as how to make the movie holder, be sure to ask a
follow up question. -
sorry guys, wasnt sure where else to put this so hope it is ok to post it here. I currently have a field in my database which stores date and time however i am writting an sql statemenet and need to only use the date of the datetime, what would be the correct syntext to do sowould i have to use to_char etc?
Thank you.Are you doing something specific to Oracle Forms? If not, you may want to consider posting your question in the SQL - PL/SQL forum (url below). If this is Forms specific, please indicate exactly which Forms version you are using. The database version you plan to use may also be helpful as there may be a variety of ways of accomplishing your goal depending on the versions.
PL/SQL -
Easy Question--External Hard Drive
My new iMac 24" will arrive in a day or two.
Here is the question:
I'm comming from XP (puke). All my photo's and iTunes music is on an external Maxtor UBS hard drive. Will I be able to plug the Maxtor into the iMac UBS and get my music and photo's???? Will the iMac OS recconnize the Maxtor?? The rest of the "stuff" on the external I'm not worried about.
Gotta have my "tunes & Photo's".
Thanks...... Man,,, NO MORE XP BLUES!YA-HOOOOOOOOO,,,,
That means that I will be able to "copy & paste" the music and Photo's on to the iMac drive??
WOW,,, what a releive!!! BIG thanks!!! You know,, in Windows, I was always afraid to even sneeze around the computer 'cause it would screw up.
Now, first thing I can get my "jams" playing!!!! -
Hello, I am new to PL/SQL. Trying to run this query against Oracle 8i:
SELECT DISTINCT DIALED_NUMBER
FROM STATDBA.FREE_CALL tb1
WHERE DIALED_NUMBER NOT IN
(SELECT DISTINCT DIALED_NUMBER
FROM STATDBA.FREE_CALL AS tb2
WHERE tb2.CALL_DATE >= TO_DATE('20050901', 'YYYYMMDD')
The error I get is ORA-00907 "missing right parenthesis".
The idea here is to get all the numbers from the talbe, which don't have any activity since 09-01-2005. What am I doing wrong?(still don't know why, but certainly fixed the problem) Because the FROM syntax does not support the use of AS when we alias table names. So Oracle treated[i] AS as the table alias and then expected a comma or something before tb2. In this respect table aliases are different to column aliases where AS is supported (but optional).
Cheers, APC -
In training, PL/SQL create table and insert question. (easy for some of you
I have an empty table called messages. The task is this:
a)Insert the numbers 1 to 10, excluding 6 and 8.
b)Commit before the end of the block.
I did this:
SET SERVEROUTPUT ON
SET VERIFY OFF
BEGIN
INSERT INTO messages VALUES (1,2,3,4,5,6,7,9,10);
END;
Which fails at messages. The table is there, I checked and it's empty. ORA-06550:Hello,
c1 is not a valid column name I posted as an example , you need to provide valid column name of your table.
Either post your table structure or replace c1, c2, c3 ... with valid column name from your table.
INSERT INTO MESSAGES (c1, c2, c3, c4, c5, c9, c10)
or
insert into messages (your table column name1 , column name2 ,....) values (....);Regards
Edited by: OrionNet on Feb 21, 2009 9:51 PM -
Hard Drive Replacement - Easy/hard?
I took my PowerBook G3 to an Apple Store yesterday to try and fix a hardware issue. It turns out that my hard drive is dead. The tech told me they were going to send it to Apple for repairs, but Apple said the model I have is considered vintage and they wouldn't repair it???????????????????????!????!
Anyway, my question is, how difficult is it to install my own hard drive so I don't have to pay someone to do it? I would assume that the drive would need some drivers installed and then the OS would have to be installed.I also have a Pismo in addition to my G4 M.T. Having upgraded several of the inner components myself,I can tell you that if you have any mechanical ability at all it will be a breeze.
I've replaced both upper and lower RAM chips, and the hard drive. It was also made even more simple by following the easy to read/follow text w/pictures from Apples G3 500mhz (Pismo) Firewire manual that is available as a download. It is in the form of a PDF file. Go to this URL and get it. Very easy to do.
http://download.info.apple.com/AppleSupportArea/Manuals/powerbooks/0340930APowerBooks.PDF
Let us know if you need any more info. You can see by the grey text here in the Apple Discussion page that I have a 60 GB 7200 RPM TravelStar replacement H.D. it doesn't heat up hardly at all. I use Photoshop and do some html programming, etc. Painter IX also.
IO took out the old H.D. went to Fry's Electronics and bought a 2.5 oinch external Firewire H.D. and put my old H.D. in to it. That won't work for you as your old one is dead. The case only cost around $30.00
Maybe you are looking for
-
Hi all, I have a slight problem here, inside my table I have a hyperlink, based on the records retrieved, this hyperlink will have different URLs. In the button_action() I have the following code: getHyperlink().setTarget("_blank"); switch(type) {
-
HT204506 Apple Pay - Watch - Adding a passcode on the watch is not working
Hi, I want to use Apple Pay and it asks me to add a passcode on the watch. The system is asking for a 6 number passcode but I keep taping on OK and nothing happens. Anyone else in the same situation?
-
Solaris 10 ldapclient problems
Hi all, I currently have an Ubuntu 9.10 server running OpenLDAP protected with self signed certs. I am trying to set up my Solaris 10u8 system as a client. I have followed the numerous online tutorials and websites, and originally had things working
-
Essbase filter assignment while importing the security through LCM
Hi Experts, My source server is Essbase standalone 11.1.2.1 and my destination is Essbase 11.1.2.4, obviously shared services security. I just created some test users/ groups/ filters in 11.1.2.4 and did export through LCM and got the actual format o
-
I use to have Photoshop CS4. One day I logged onto my computer and got on Photoshop and all of my actions were gone. I thought that was the first and last time I would have that problem. Well I now have Photoshop CC (and have had it for a few months)