Merge Two Tables with the same columns but different data

I have a table that has the following columns:
Current Table Definition
commonname
family
genus
species
subspecies
code
I have a number of entries that don’t fit the current table definition – that is that they only have a common name or description and a code. These records don’t actually represent a species but are needed for data entry because they represent an object that may be encountered in the study (Bare Ground – which isn’t a species but would need to be recorded if encountered). So I would really like 2 tables:
Table 1 Miscellaneous
name
code
Table 2 Plant Species
commonname
family
genus
species
subspecies
code
I would like two tables so I can enforce certain constraints on my species table like requiring that the family, genus, species, subspecies combination is unique. I can’t do this if I have all the “other” records that don’t have a family, genus, species, or subspecies unless I put in a lot of dummy data into the fields to make each record unique. I don’t really want to do this because these miscellaneous records really don’t represent a specific species.
So – the problem is that while I want this data separate I will need to point a column from another table to the code column in both tables.
How is this best done? Table? View? Merge?

Hi,
Actually you don't have to use scope refs. Sorry but I misunderstood you earlier. Here is a complete example that does exactly what you want. Notice how I added the constraint to the materialized view. Also notice when we try to insert a code in tbl3 that doesn't exist in the view, we get an error. HTH.
SQL> create table tbl1 (name varchar2(10), code varchar2(3) primary key);
Table created.
SQL> create table tbl2 (commonname varchar2(10), code varchar2(3) primary key);
Table created.
SQL> insert into tbl1 values ('n1','c1');
1 row created.
SQL> insert into tbl1 values ('n2','c2');
1 row created.
SQL> insert into tbl1 values ('n3','c3');
1 row created.
SQL> insert into tbl2 values ('name1','c1');
1 row created.
SQL> insert into tbl2 values ('name2','c2');
1 row created.
SQL> insert into tbl2 values ('name3','c3');
1 row created.
SQL> commit;
Commit complete.
SQL> create materialized view view1 as select name, commonname, tbl1.code from tbl1, tbl2 where tbl1.code = tbl2.code;
Materialized view created.
SQL> select * from view1;
NAME COMMONNAME COD
n1 name1 c1
n2 name2 c2
n3 name3 c3
SQL> create table tbl3 (code varchar2(3), record varchar2(1));
Table created.
SQL> alter table view1 add constraint view1pk primary key (code); -- <-Note how I added a constraint to the view
Table altered.
SQL> alter table tbl3 add constraint tbl3fk foreign key (code) references view1(code);
Table altered.
SQL> insert into tbl3 values ('c1','r');
1 row created.
SQL> insert into tbl3 values ('c99','r');
insert into tbl3 values ('c99','r')
ERROR at line 1:
ORA-02291: integrity constraint (RAJS.TBL3FK) violated - parent key not found
SQL> spool of;
-Raj Suchak
[email protected]

Similar Messages

  • Two database with the same sid but different ORACLE_HOME on one host

    two database with the same sid but different
    ORACLE_HOME on one host,and if configure them with
    two differnt lisnter staticaclly,this abosultely work
    because in the lisnter.ora we must provice
    ORACLE_HOME variable,with this ORACLE_HOME the client
    can differentiate which database to connect,but if
    use dynamically register feature,how can the client
    tell which database to connect?

    Also note that this type of configurtion may not be supported.
    Just because a given configuration works in certain given conditions does not mean that it would be supported.
    If this setup is for a configuration that has any value, please also Contact Oracle Support to get their inputs on what you are trying to accomplish.

  • Why can't iTunes down load two songs with the same name but different artists to my iPhone?

    I noticed this a couple of years ago but had forgotten about it. Today I purchased two songs, both called Bop Gun (One Nation) but by different artists. When I looked at the purchased list on one appears. If I go back to iTunes and download the other one, the former disappears. Are they honestly saying that these phones are intelligent enough to distinguish a song by artist rather than track listing?
    Epic Fail!!!

    Usually a song is uniquely identified by song name, artist, album and track number. That said internally I suspect the iTunes Store may allow one song to appear on more than one album while they only need to store one copy of the audio data. (They must also be able to cope with the situation, for example, where the UK & US version of an album have a different track order). It is also possible there is an error in the database that means you're not getting the song you're expecting. If you can't successfully download the two (presumably) different versions of the song then use the report a problem links in your account history and explain the issue. Hopefully the iTunes Store support staff can get it resolved.
    tt2

  • When i open a website, i get two tabs with the same address but different icons?

    when i open a webiste, i use google, another tab for the same website appears but with a different logo. macafee says it's not a virus, and to contact firefox.
    i am not a computer person and i don't know how to get rid of the second tab
    appreciate any help! :-)

    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • When i open a website, i get two tabs with the same website but different icons?

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/938844]]</blockquote>
    i am not sure how else to explain it- i open a link on firefox and then 2 tabs open for the same site

    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • PFCG, two roles with the same object but different values

    Hi, Can you help me?
    I need to know if it's possible have two roles like this:
    role A - Object werks = L001 and LIKP-LFART = LF
    role B - Object werks = L005 and LIKP-LFART = ZLF
    If the some user have role A and role B it's possible that he doesn't have authorization for werks = L005 and LIKP-LFART LF?
    Thanks
    Dora

    I guess you made fat figure on the words: "it's possible that he doesn't have authorization for werks = L005 and LIKP-LFART ZLF", right?
    If so, it is impossible.
    When SAP doing the authorization check, it call the function "authority_check", input the Object, the filed and the value to check.
    if some one have role A and B, SAP will check authority both in Role A and Role B.
    What you need to do should be separating the Object into a subrole and assign it separately.
    >
    Jorge Sousa wrote:
    > Hi, Can you help me?
    > I need to know if it's possible have two roles like this:
    > role A - Object werks = L001 and LIKP-LFART = LF
    > role B - Object werks = L005 and LIKP-LFART = ZLF
    > If the some user have role A and role B it's possible that he doesn't have authorization for werks = L005 and LIKP-LFART LF?
    >
    > Thanks
    >
    > Dora

  • Is it possible to have 2 trans with the same tcode but different langs

    Dear forum members,
    I would like to know if it is possible to have in the TSTCT table u2013 two entries with the same TCODE value but different SPRAS value (the language field)
    Thanks for your help,
    Roy

    Hi Roy,
    It is possible. Just go to TSTCT table and check for the entries. On the selection screen give some Tcode (say OKEU) and execute. You can see different languages in which it is maintained.
    Regards,
    Swapna.

  • Two AM's with the same name but different forms causes Deployment problems

    Two Masters forms, DOC & PM are cloned except for the "where clause" in the View's query and the titles in their JSP's.
    DOC workspace has a BC project and a BC4JSP Project. The BC project comprises of the EO and VO named ComVsStaticValue. In the Edit prop-> query for the VO I have specified the "where clause" as VSSV_VS_CODE='DOCTOR'.
    In Java Webserver :-
    The JSP's are located in C:\source\Doctor\ .. and the *.xml and *.class files generated by the BC proj is in C:\source\Doctor\pol_ValueSet\..
    If I execute Doctor in JWS the records are getting filtered properly.
    PM workspace has a BC project and a BC4JSP Project. Again The BC project comprises of the EO and VO named ComVsStaticValue. In the Edit prop-> query for the VO I have specified the "where clause" as VSSV_VS_CODE='PAY_MODE'.
    In Java Webserver :-
    The JSP's are located in C:\source\PMode\ .. and the *.xml and *.class files generated by the BC proj is in C:\source\PMode\pol_ValueSet\..
    If I execute PM in JWS, the PM's JSP comes (the title is correct) but the records pertaining to DOC appears. I checked the View's xml file in C:\source\PMode\pol_ValueSet\ the "where clause" is correct. The xml & classes have the same name but their contents are different.
    I want to know whether this problem is because both have the same name for the AM and the BC4JSP's property file.
    Please clarify.

    Deploying two app modules with the same name will definitely cause problems.
    The JSPs use the information in the properties file to connect to the application module and get the data they need from the appropriate View Objects in those app modules. If you have two app modules with the same name, when a JSP tries to connect, it has no way of knowing which one of the app modules to connect to if they both have the same name.
    You could:
    1. Just use one application module that contains all the View Objects you need to access.
    or
    2. Rename one of the application modules or the package it is located in so the names are distinct. If you choose this method, you will also need to update the JSPs (specifically the 'registerApplicationFrompPopertyFile' method call), and your JSP project's appmodule property file.

  • Join two tables with the same information

    I have a registration database. It references two other tables. I accept registrations from Faculty and from Students, but their information is in two different tables. Both have fname and lname. If they have people_id filled in, I want the fname and lname from the People table. If they have student_id filled in, I want it from the Student table.
    I've never done this sort of IF situation. Here are the tables:
    create table passport_registration (
         passport_registration_id NUMBER Primary Key,
         date_added date,
         student_id NUMBER REFERENCES students(student_id),
         people_id NUMBER REFERENCES people(id),
         passport_listing_id NUMBER REFERENCES passport_listing(passport_listing_id)
    create table PEOPLE (
    id NUMBER Primary Key,
    dateModified date,
    fname VARCHAR2(100),
    lname VARCHAR2(100)
    create table students (
         student_id NUMBER Primary Key,
         date_added date,
         s_uid VARCHAR2(50),
         fname VARCHAR2(50),
         lname VARCHAR2(50)
    Any sort of assistance is appreciated.
    Thank you.
    daniel

    (It'd be helpful if you could edit your post and stick {noformat} before and after your sql statement - that will format it so that the (+){noformat} show correctly instead of being converted to the (+) symbol!)
    As to the questions:
    1. You've got two columns that have a decision to be made on them; you're going to need to write two sets of decision-making code, one for each column. I guess you could also do something like:select a.col1, d.col2, d.col3
    from table1 a, (select 'table2' cola, b.col1, b.col2, b.col3 from table2 b
    union all
    select 'table3' cola, c.col1, c.col2, c.col3 from table3 c) d
    where a.col1 = d.col1
    and nvl2(a.col2, 'table3', 'table2') = d.cola;
    nb, not tested, and I'm up far too late, so could have made an easy mistake!
    2. Yes, {noformat} (+){noformat} is the oracle method of doing outer joins; it could be rewritten into ansi joins if you like; I'm just not that familiar with them to do it myself!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Two tables with the same selectionModel

    Hi to all..
    I have been working on a project in java that needs to include two tables.Right now, I have successfully
    built two tables (Table A and B) with different type of data from a database and each of it will update when user click a button.
    The problem that i have is how to make sure that when user click a row in Table A, any selection in Table B will be deselect.
    I am new in programming and still barely understand in Swing components.
    Thanks.
    Amy

    where should I put the line of code.add a mouse listener in table A
    put the code on mousePressed.
    e.g.
    tableA.addMouseListener(new java.awt.event.MouseListener() {
                public void mouseClicked(MouseEvent e) {
                public void mouseEntered(MouseEvent e) {
                public void mouseExited(MouseEvent e) {
                public void mousePressed(MouseEvent e) {
                    tableB.clearSelection();
                public void mouseReleased(MouseEvent e) {
            });

  • Is it possible to have 2 instances with the same name but different edition in the same server?

    Hi everybody!
    I have in a little trouble ....
    *** Scenario.
    Oracle Enterprise Edition 11gr2 over Oracle Solaris 11
    3 instances: PROD, QA, DEV
    1 ASM instance
    Listener ports: 1520, 1530 & 1540
               Those are production system
    *** The problem:
    Customer can't pay Oracle EE, they want to change to Oracle Std One
    Limitations:
    I cant have a similar system to test.
    *** My idea:
    Install Oracle Std One, in the same path:
    /u01/app/oracle/product/11.2.0/db          <-- EE
    /u01/app/oracle/product/11.2.0/db_one   <-- Std Ed One
    ASM:
    /u01/app/11.2.0/grid          <-- EE                    +ASM
    /u01/app/11.2.0/grid_one   <-- Std Ed One        +ASM1
    Create databases:
    Asign similar disks to +ASM1
    Create DGs on +ASM1
    Create databases: PROD, QA, DEV for Std Ed one
    - is it posible that they have same instance name?
    - if not, i suppose create as: PROD1, QA1, DEV1
    Configure Listener port : 1521, 1531 & 1541
    Migration technique:
    Create Tablespaces, schemas
    Lock users in EE
    down listener: 1520, 1530 & 1540
    Import data of final users in a window maintanance
    configure and up listener: 1521, 1531 & 1541
    Customer should test access and apps in new
    Please tell me if my Idea is reallistic, all comments are going to be very apreciated.

    sol.beach
    I suppose end customer use a port per database in order to separate in a logical way the access to the databases,
    i mean PROD, QA & DEV has the same users.
    Hemant K Chitale
    1. I've seen physical servers with 3 ASM instances: +ASM1, +ASM2, +ASM3
       on Solaris & Oracle 10g, I suppose is posible on 11g
    2. The sever has occupied 2  sockets (2 physical CPU), so I can use Oracle Standard Ed One.
    JohnWatson2
    Thanks for your comments.
    WadhahDaouehi
    1. - You cannot run two ASM instance simultaneously on one Server, but you can run many Oracle database simultaneously
          on the same server which they use the ASM as storage type.
      As a mentioned to  Hemant K Chitale, I've seen a system with several instances running
      About
         "you can run many Oracle database simultaneously on the same server which they use the ASM as storage type."
      I'm not sure if i can use the same ASM which is part of a current Enterprise Ed over the new installation with Oracle Std Ed One.
    2. - Why you want the same instance name?
    If it is about the service name, which has by default the same instance name, just you can create a different instance name
    and create the service name with the name that you wish.
    SQL> alter system set service_names='instance_name';
    Is a similar name, not the same
    PROD, QA & DEV
    PROD1, QA1 & DEV1
    I consider add "1" at the end to refer "Oracle Standar Ed One"
    But I agree with you, i can customize throught service_name.
    Regards,
    Abraham Mtz.

  • How do i back up 2 different devices with the same ID but different content, without losing any content?

    I have 2 iPads but just one ID. I use the iPad 2 and my daughter uses the mini. Both have different contents, as her mini contains a lot of videos that she's taken. Niw, I just bought an iPad Air and want to essentially transfer my iPad 2 contents there and also transfer my daughter's mini contents to that iPad 2. If I back up both to the same computer, will I have access to both sets of content and transfer the data to whichever device as I see fit? I just want to make sure so I don't lose any of her content (especially).
    Thanks!

    Using iTunes on a computer, be sure to set the backup(s) to be stored locally and not the iCloud for efficiency's sake. If all devices belong to the same AppleID, each one will store its backup on a separate file, and if appropriate, you can choose any for a restore as needed. As shown in Diavonex pic, the backups are listed in Preferences / Devices. Hover the cursor over each and a popup will appear detailing which device it belongs to. And you can keep, if needed, more than one backup of a device: control-click on the backup to preserve and choose Archive from the menu (Older backups get overwritten otherwise).

  • I have two libraries on the same computer but different logins, there is my user account for the computer and then there is my grandma's, how do i get my music without having to resync on both libraries?

    this computer has two logins, my grandma's (which is the administrator) and mine, itunes is on both logins but on my login i have some music there and hers i have my other music.. i want to be able to redownload my music on my ipod touch with out having to resync back and forth between libraries.. how do i combine the libraries because if i go with one or the other i lose my music i have purchased, on both libaries the music belongs to me not my grandma,
    Also, a few weeks ago, I loaned the IPOD to somebody and they told me that evidently the IPOD had been hacked and that it had lost all the music.  When I got it back, I re-synced it and got some of the music back.  After talking to other people, I now suspect that my "friend" tried to do something he wasn't suppose to to and the IPOD shut down or that he was trying to create an Apple ID of his own without paying for it.  Now that I have it back, I just want to get the music back that I paid for that is already associated with my ID and that is in my two libraries.  I can see them in there (on the computer), I just can't access them to download  them on the IPOD.  Can you help?

    There are actually a few methods for using more than one iPod on a single computer: How To Use Multiple iPods with One Computer
    Just to summarise what's in the link above:
    Method one is to have two Mac or Windows user accounts which by definition would give you two completely separate libraries.
    Method two is to set your preferences so that either one or both iPods get updated with only certain playlists within one library. If you've had no success with this you can have a look through the guide on this page: Loading songs onto iPod automatically
    Another option when using a single library is to set one or both of the iPods to manual update: Managing content manually on iPod
    You can read about Windows user accounts here: Using Windows XP User Accounts

  • Is it possible to have 2 tables with the same name in an Orable database?

    Hello,
    I'm a complete Oracle newbie so please excuse my question if it's stupid.
    I was trying to create 2 tables with the same name using different tablespaces but it does not seem to work. Like this (second time just change the name of the tablespace):
    CREATE TABLE test_tbl (
      id INTEGER,
      status VARCHAR2(10),
      last_modified DATE DEFAULT SYSDATE
    TABLESPACE tblspc1Is it in general in Oracle possible to acquire this goal?
    Thanks a lot!
    P.S. I have already created the needed tablespaces
    CREATE TABLESPACE tblspc1 DATAFILE 'tblspc1.dbf' SIZE 10MEdited by: 808239 on 02-Mar-2011 02:18

    It is not possible to create two tables with same name in same schema.
    A user can own one schema with his own name and another with the schema name SYS.
    For this you have to grant sysdba privilage to the user and then have to connect using sys password or with the password specified in password file.
    But this still you have to access to the table in sys schema using sys.table_name.
    Hope Answered tthe Question.

  • How can I let firefox save usernames/passwords for multiple subdomains that use the same username but different passwords?

    on a particular website that has sub domains I have multiple accounts with the same name but different password. Firefox seems only able to save one of them, because they are on the same site.

    "Things"?  What things?  Apps for keeping track of when to change cat litter?  30 different versions of "twinkle, twinkle little star" played by everything from punk rockers to Gregorian chant?  Videos on the best way to make Christmas cake?

Maybe you are looking for

  • How can I erase all photos in one album at once.

    Over the years 25.000+ photos are on my Mac filling up the hard drive. I want to store a big number on my server, but keep some on the Mac. So I made Albums with assorted pics that I want to store in the server in groups to find them back. I export t

  • CSS Layout Anomoly

    I have been trying to be a very good boy recently and learn to layout a website using CSS and layers. I have created a test page that pretty much seems to work. I have used a wrapper div with a background image so that the main body column and the ri

  • Question about self defined Application monitoring object

    Hi I m trying to define my own monitoring objects, but what defined in the monitored system can not appear in solution manager(4.0). I have newest version of sap-a/pi , the ST-PI is 2005_1_700, any one can drop me some lines where coulde be the probl

  • Bringing php data into flash file

    I've got a php file, below is the code from it: <?php $dir = "photos/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { $fileList = ""; while (($file = readdir($dh)) !== false) { if ($file !=

  • Mavericks install disables apps

    After up grading to the latest OS X Mavericks installation the following apps do not function Finder Maps Calendar Contacts Time Machine I have completed a re installation ... no change Others say something wrong with my HDD Disk utility says nothing