Create a key to a view foreign Mat?

You can create a key foreign to a view mast?

I try, but it doesn't seem to work. I use Oracle 10.2.0.4.0

create table myproj in select * from caa_project;

ALTER table MyProj to add the constraint x key PRIMARY (ppm_proj_nam);

Create materialized view refresh build testvw IMMEDIATE enable complete rewrite of query like select distinct cawp_v2 ppm_proj_nam
;

create an index only testvwi on testvw (ppm_proj_nam);

MyProj ALTER TABLE ADD CONSTRAINT CAA_PROJECT_FK1
(FOREIGN KEY)
PPM_PROJ_NAM
)
REFERENCES testvw
(
PPM_proj_nam
) ;


I get "no matching unique or primary key for this list of columns" Ora-02270

I'm doing something wrong or is this all just not supported?

Thank you.

try to use

ALTER table testvw add constraint testvw_u unique (ppm_proj_nam) or
ALTER table testvw add the key primary constraint testvw_pk (ppm_proj_nam)

Instead of

create an index only testvwi on testvw (ppm_proj_nam);

I created this constraint for oracle 10.2.0.4 DB

Concerning
Andrey

Tags: Database

Similar Questions

  • Why create a primary key on a VIEW?

    One of our developers found that you can define a primary key on a VIEW. What are the circumstances which justify the something like that?

    -= Chuck

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:636499119911

    "
    Tom,

    I'm a little confused on the constraints on views. According to the documentation, they are not applied. Then
    What is the use for the constraints on views?

    According to the "SQL Reference": documents

    Constraints of view (the view and the column level or attribute) are declarative. It's
    Oracle does not apply to them. However, the operations on views are subject to constraints of integrity
    defined on the underlying base tables, then you can apply constraints on views through constraints
    on the base tables.

    Thanks for your time.

    Follow-up February 5, 2002-11:00 Central time zone:

    They are used for rewriting complex query with other materialized views. It's more "metadata".
    -It gives additional information from the optimizer, allows a wider range of the rewrite of the query to
    place.
    "

  • Constraints foreign key in materialized views can be changed (approx 1-master)

    I have a system which consists of a master database and a bunch of materialized view sites homogeneous. 10.2.0.4 all around. Main server is Windows Server 2003. all remote nodes are Windows XP. All materialized views are editable. There are only 20 or two tables (materialized views). Users enter data in the system at the level of the remote nodes via an application.

    There are data integrity constraints in the database on the main site. In the hunt for replication errors, I discovered that the integrity constraints do not exist in the context of the remote node. Then, sometimes, that users can enter data not valid that main site integrity constraints disallow, producing errors of replication on the master site. For a test I then implemented manually some of the constraints on a remote node using the java Enterprise Manager UI. Constraints have behaved as expected, as far as I can tell.

    My ultimate goal is to implement, on all sites of the materialized view, the current constraints of the integrity of the main site, so that entering data at remote sites is governed by the integrity constraints.

    I looked briefly package DBMS_REPCAT subprograms. Nothing jumped out at me.

    I started to collect the DDL (ALTER TABLE... ADD CONSTRAINT...) I could run each site through SQL * more sheet calculation.

    Then I thought that maybe I could use sqldeveloper to run the DDL but when I open the relevant schema to the level of the remote nodes, the actual tables are not shown, only the USLOG$ _... things. Materialized views are shown - but they do not have a constraints tab.

    After some time in the manuals, I decided that I have a good knowledge of what I see; and that's why I'm not sure I'm running in the right direction.

    I will summarize two questions:

    (1) what is the best way for me to apply constraints of integrity of the master site existing in materialized views can be changed on all nodes?

    (2) why I can see and work on the tables on the remote nodes via the EM java, but don't can't see them via sqldeveloper, logged in with the same account twice?

    P.S. It is possible for me to delete and re-create all databases and the views materialized on all remote nodes. It is not a high volume system, and there are windows of time during which I can do these things if necessary. I don't expect a structural change to the database, so I don't need to be able to spread future changes, just make things sync'd up now.

    Published by: Clark October 10, 2008 11:38

    Hi Clark,.
    you are right THAT FK on mviews can cause many problems during refresh. I mentioned on delete cascade, but delete the null value or remove restricted can cause problem too. You cannot complete with active reftesh FK referencing MV PK.

    Because you cannot control the mviews refresh a refresh Group, that the problems I described before can occur.
    You have to my view of these possibilities:
    1 / move Ref. integrity check from the DB to the logic of the application
    2 / use triggers to maintain ref.integrity check DB
    3 / mutlimaster user instead of mviews replication

    But none of them have their more and less.
    1 / + FK is checked - take some time, any other manipulation of data through the application can break rules FK
    2 / + FK is cheked on DB level - you write triggers, lower performance, changing disorders tables
    3 / + FK is chedked at the DB level, - all the data is replicated on the table plan (for MV, you can define where cluase for replication mutlimaster not), with more than two masters, it is difficult to define the replication conflict resolition method that convert in the last time.

    Last post:
    I my case I use this "thing":
    Because our request has not been managed in environment 24 x 7 I wrote my own routine to refresh.
    This routine that follows:
    1 / disable necessary FK
    2 / call dbms_refresh.refresh to perform the refresh of the refresh Group
    3 / activate FK disabled in step 1 with the novalidate
    Refresh the jobs was launched at night.

  • Key Reg primary and foreign at the same table

    Hello

    It is - ok if create primary and foreign keys on the same table itself?

    For example:

    In a table X, I have two columns such as Codeunite and ParentUnitcode.
    Is it ok if create Mt10 as principal and ParentUnitcode as foreign keys in the table itself?

    The foreign key base table: OrganizationalUnit
    Foreign key columns: ParentUnitCode
    Primary/Unique key base: OrganizationalUnit
    Primary/unique key col: Mt10

    Can anyone answer me on that?

    Concerning
    Rajesh

    OWB,

    If the two tables are favouring a one-to-one relationship so there no need to have two separate tables and so you can have free referential foreign keys in the same table where the primary key.

  • Yet WT8 - BITLOCK-how to create a key?

    Hi all.

    I have no need of BitLock on my Toshiba WT8 yet, but if you read my last post, you will see that he did a heck of a headache.

    To reduce the risk to be locked AGAIN somehow or other, I don't know how it happened the last time that I didn't activate or touch all the parameters relating to the BitLock) to my knowledge.

    As stated I have no need for this, nor do I have any knowledge in its use.

    I would like this does not happen, so I'll ask a few questions and you can help me please.

    I do not remember, but when the Tablet is first turned on and being prepared I get presented with the option/setting to enable/disable the Bitlocker?

    If not, and the operating system was set in motion, to access Bitlocker (on my Windows 7 PC desktop I'll in the Panel, I suppose that the table would be substantially the same).

    Now when the Bitlock icon has been clicked and it opens, that I have to actually activate it by clicking/tapping/ticking or else create a key, or can I create a key in the Bitlock window without it actually start/turn on the program?

    Concerning

    To be honest it s not I know if you will be asked to configure the Bitlocker configuration first.
    But as the bitlocker is a feature advanced Windows system and not available for all the Windows system, I think that this option is not in the first configuration.

    However, the Bitlocker is a feature of Microsoft Windows, and if you want more details on the features, I recommend you to check the page MS Bitlocker
    FAQ:
    https://TechNet.Microsoft.com/en-us/library/hh831507

    What's new in Bitlocker:
    https://TechNet.Microsoft.com/en-us/library/dn306081

  • can I create a key for key restart (windows) on the Helpsite Ergo 4000 keyboard?

    Original title: MS Ergo 4000 kb.

    Hey

    Should be easy. On my old or dead logitech keyboard had a touch restart (windows). can I create a key for this custom 4000?
    I looked into the keyboard software, but didn't find any option.

    Thank you

    P. S.

    Why is it I already signed in the community, I took particapate then he forced me to start a new connection?
    Now I have 2 connections 1. bradfeuerhelm 2.bradfeuerhelm1954! Also your hardware forum is not listed in the category!

    Hi Brad,

    Microsoft keyboard you can reassign some keys to access the various commands, shortcuts or IntelliType Pro features to better fit your work style.

    How to redirect to my keyboard access keys?

    http://www.Microsoft.com/hardware/en-GB/help/support/how-to/keyboard/reassign-keys

    You can also create shortcuts keyboard that contains the executable program file.

    (a) right click on desktop

    (b) click on new > shortcut

    (c) type "shutdown.exe - r-t 00" click Next

    (d) type the name as "restart", and then click Ok

    (e) click right to restart the icon on the desktop

    (f) click Properties, and then click the shortcut key

    (g) you can press Ctrl + Alt + R or according to the letter that you like.

    h) click 'Applies' > Ok

    (i) now when you press the shortcut key, your computer will restart.

    (j) don't forget to quickly save everything before you press the shortcut key.

    For more information, see this link:

    Create keyboard shortcuts to open programs

    http://Windows.Microsoft.com/en-GB/Windows/create-keyboard-shortcuts-open-programs#1TC=Windows-7

    You can use a single Microsoft live id to connect to the Microsoft Community website. You can give different names, you want to appear on the thread by changing the profile display name.

    (a) sign in tohttp://answers.microsoft.com/en-us using your Windows live ID.

    (b) click on your user name, then click on edit profile.

    (c) change the nickname you like.

    I hope this helps. If you need help with Windows, let us know and will be happy to help you.

  • Union - generator of grid view layout query error could not create the checkerboard to correct view

    I get the error while I'm trying to run a simple union query below. The query uses simple areas. I use columns the same type of data in the same order in each of the areas and when I run the sql generated backend query, it returns the correct result. Only in obiee front end, it is not showing any result but giving the below error instead. I use version 11.1.1.6.8 Please help!

    The presentation view grid generator could not create the checkerboard to correct view. It lacked the logical column with the following ID: c6d9af7a1de3ca97a.

    Error details

    Error codes: WUSYDB5K

    Geographical area: saw.views.evc.activate, saw.httpserver.processrequest, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.

    handleConnection, saw.rpc.server.dispatch, saw.threadpool.socketrpcserver, saw.threads

    This is a bug, you must connect your environment to min 11.1.1.6.10 max 11.1.1.6.12/11.1.1.7.x

  • How to create a trigger on a view

    Hi all

    I am trying to create a trigger on a view that is used to update a few columns in the base table. As I am new to the trigger, an example will be appreciated.

    Thanks in advance.

    You would probably be, test the trigger by performing an insert or an update on the view in question and checking that the trigger did what you expected for the base tables.

    Justin

  • Another syntax for creating primary key


    Hello


    I have a question about the right way to create primary keys.
    Earlier, we were on Oracle 9i and we have upgraded to Oracle 10 g. The question is when creating primary key is allowed to create the unique index and then to create the primary key constraint? or directly create the first key is better? or are there ways to both the same?


    for example:
    one way:


    SQL & gt; CONN u2/u2@db1
    Connected.
    SQL & gt; create table a (a1, b1 varchar2 number (2), the date c1);


    Table created.


    SQL & gt; create an index on a (a1) tablespace unique pk_a t1;


    The index is created.



    SQL & gt; ALTER table a Add (constraint primary key (a1) using index pk_a);


    Modified table.
    Another way:
    SQL & gt; CONN u1/u1@db1
    Connected.
    SQL & gt; create table a (a1, b1 varchar2 number (2), the date c1)
    2.


    Table created.


    SQL & gt;
    SQL & gt; ALTER table a Add (constraint primary key (a1) using index tablespace t1 pk_a)
    2.


    Modified table.
    Which of the two approach is better? or are they the same?


    Thank you
    Cedric

    Oracle will attempt to create the index to apply the constraint. Of course, it is certainly possible that the creation of the index will fail, but you would be just to move the point of failure of the CREATE INDEX statement to the ALTER TABLE statement, assuming that everything else is equal (that is, you create the index in the same tablespace, quotas and tablespace sizes are the same, permissions are not changed, etc.)

    It may be preferable in some contexts to create a non-unique index before the creation of the constraint and instruct Oracle to use the non-unique index to apply the constraint. If you decide in the future to make the primary key constraint can be delayed, for example, have a non-unique index allows you to make this change without having to (implicitly), drop and re-create the index. A separate CREATE INDEX statement also influences when you go to remove a constraint / index. If the index was created before the constraint, you can remove the constraint without affecting the index. If the index was created after the constraint, deleting the constraint implicitly removes the index. Normally, particularly with OLTP applications, this doesn't buy you much. Sometimes, however, there are ETL process benefiting from such things.

    Justin

  • type a materialized view foreign key constraint?

    Hello.

    I have a materialized view that flows into a single column 'A' two different columns of different tables of a remote database.

    I also have a table that has a column 'B', whose values must exist in the column 'A' of the materialized view.

    So it's like defining a constraint foreign key of a table to a view, but this is not possible.

    Is it possible to do?

    I saw some triggers that verify the existence of the 'A' value before insertion in 'B', but this fails when a value is changed or deleted in 'A'

    Any suggestions?

    Thank you very much.

    Published by: user7029403 on 18-ene-2013 03:57

    There is no problem of definition of a primary key on a materialized view and then reference it with a foreign key. It works for me:

    create database link l1 connect to scott identified by tiger using 'orcl';
    create materialized view mv1 as select deptno||dname as a from dept@l1;
    alter table mv1 add constraint mv1pk primary key (a);
    alter table dept add (fkcol as (deptno||dname));
    alter table dept add constraint deptfk foreign key (fkcol) references mv1;
    

    I don't know there is a more elegant solution than to use a virtual column, which seemed the best way to get around the concatenation of two columns in a single

  • Unique key and foreign key in the view of materialzied

    Hello world
    I have one main site and 4 materialized view sites.
    In my main site, I did a main group that contains my tables participating in replication.
    I have a table that has a primary key, foreign key constraint unique.
    In my first materialized view site I did group for my opinion

    BEGIN
    DBMS_REPCAT. () CREATE_MVIEW_REPGROUP
    gname = > "hr_repg"
    Master = > "orc1.com"
    propagation_mode = > 'ASYNCHRONOUS');
    END;
    /

    BEGIN
    DBMS_REFRESH. DO)
    name = > 'mviewadmin.hr_refg ',.
    list = > ",
    next_date = > SYSDATE,.
    interval = > 'SYSDATE + 1/144',.
    implicit_destroy = > FALSE,
    rollback_seg = > ",
    push_deferred_rpc = > TRUE,
    refresh_after_errors = > FALSE);
    END;
    /

    Then I created the materialized view

    HR.test CREATE MATERIALIZED VIEW
    COOL OFF QUICKLY WITH A PRIMARY FOR THE UPDATE KEY
    AS SELECT * FROM [email protected]
    /

    BEGIN
    DBMS_REPCAT. () CREATE_MVIEW_REPOBJECT
    gname = > "hr_repg"
    sName = > 'hr ',.
    oname = > 'test ',.
    Type = > "SNAPSHOT."
    min_communication = > TRUE);
    END;
    /

    BEGIN
    DBMS_REFRESH. ADD)
    name = > 'mviewadmin.hr_refg ',.
    list = > "hr_test.test"
    Lax = > TRUE);
    END;
    /

    When I check the test (materialized view) table in the site of the materialized view to a primary key, but it has no foreign key forced unique having the base table and because my test materialized view can be changed I need to have these 2 constraint on my my materialized view. You have an idea why these 2 constraint were not created on my materialized view? And what should I do to have these two constraints.

    Thanks in advance

    On MView is created automatically only PK. Other constraints (check, not null, unique or FK) should be created manulay. Indexes also.
    But be careful with the FK.
    On ORACLE8, I found lines that are inserted to updatable mview back in deleted updating process, then inserted (downloaded on the main site). When FK is with on delete cascade that the lines of the child tables (mviews are removed too). And when the child mview is updated before mview parent you found the child missing lines.
    When CF is on delete restrict that you refresh the process fails.

  • Should I create primary keys or foreign first?

    I'm new to sql and a student please bear with me.

    I create a script so that when I run a sequence of tables are created. I created all of my fine tables but now I want to add the primary and foreign keys. I tried to do all this at once before but had problems, my idea was to use alter table instructions and add the constraints of key primary and foreign in this way.

    The thing I want to know is what to build first? Should I do any foreign keys and primary keys or visa versa? Or can I do them sequentially and connect relationships between the tables that I will. Thanks in advance!

    Hello

    One thing to remember as a student is to apply logic to the task at hand. In this case, to create a foreign key, it must refer to a primary key in its definition as well so the KP must exist first. What I tend to do is to break down as statements in separate files or sections separate scripts and execute it in a logical order. IE Tables first, and then of PK and UK followed by the FK etc.. I also prefer to create offline rather than constraints in create table statements.

    Hope this helps

    André

  • Three ways to join with key primary and composite foreign

    Hi all

    I have three tables

    1 - test_data_items (test_data_item_id pk

    test_data_item_name)

    2 - data_items_in_tests (test_id, test_data_item_id) - both are a composite primary key.

    3 - test_results (test_results_id, pk,

    test_admin_id,

    test_id, test_data_item_id)-both are a composite foreign key.

    How to reach the three tables?

    I want all the data, but I don't know how to write the join conditions when there are primary and foreign keys composite?

    Thank you very much

    Hello

    Any condition (including a join condition) may be a compound of 2 or more of the simple conditions, combined using AND or OR.

    Maybe that's what you want:

    SELECT *- or the columns that you want to the list

    Test_data_items I have

    JOIN data_items_in_test d.test_data_item_id d = i.test_data_item_id

    JOIN test_results r ON r.test_data_item_id = d.test_data_item_id

    AND r.test_id = d.test_id

    ;

    In this case, the join condition between tables d and r is a compound of 2 simple conditions, combined with the help of and.

    The above query is just a guess.  There is not necessarily a unique way to join any 2 tables given.  Aptly named columns (and yours seem to have good names) and foreign key constraints can help you make better guesses about how to join the tables, but they are still all speculation.  They same 2 tables can be attached in different ways, depending on what is in the tables and what results you expect from them.  It's one of the reasons why, whenever you post a question, you must post a small example data (CREATE TABLE and INSERT statements), the results that you want from this data, as well as an explanation of how you get these results from these data.

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • Create a report based on view

    Hi all

    I wanted to create a form with report based on two tables:

    1. I created a display (called COMBO) based on two tables
    2. I then created a form with the opinion-based report

    Until then, everything seemed fine until I tried to edit existing records - I get the error:
    ORA-20505: Error in DML: p_rowid=2002082600001172, p_alt_rowid=REPATRIATION_ID, p_rowid2=, p_alt_rowid2=. ORA-01776: cannot modify more than one base table through a join view 
    
    Unable to process row of table COMBO.
    Note: REPATRIATION_ID is the primary key of the table of repatriation. The other table is a plaintiff.

    & when I tried to create a new record - I got the error:
    ORA-01776: cannot modify more than one base table through a join view 
    
    Unable to process row of table COMBO.
    Someone enlighten me please!

    Kind regards
    Kamo

    Published by: Kamo 03/12/2009 02:33

    Hi Kamo,

    You create a trigger of "instead of" (insert/update/delete) on your sight to treat inserts etc in the tables 'real '.

    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this response in marking it as useful or Correct ;-)

  • Error creating registry key, RegCreateKeyEx failed; Code 5 access denied

    Just as the title says. I encounter and error where a program is unable to create a registry key. Error 5, access denied. I tried as admin and the problem still persists. I tried to run the registry editor and access, but still the problem persists.

    For the complete error message:

    HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/MediaProperties/PrivateProperties/Joystick/OEM/V8/AXES/0ID_8888 & PID_030

    RegCreateKeyEx failed; Code 5 access denied

    I can retry, ignore, stop the program. I run Windows 7. It is a big problem for me because this PC is also to play games, can't really do this without my will.

    I solved the problem some time ago btu don't remember how. I think trying to let the program us firewall or try to disable all firewall and installed, I'm pretty sure something along these lines has helped.

Maybe you are looking for

  • Pavilion 6610f: what is my validation key number OS

    Computer HP Desktop Pavilion 6610f 64 bit OS Win 7 Home Premium Wireless and Ethernet connection of the power cord Bought more than 6 years ago.  Win 7 operating system came preloaded.  It's the same operating system that I used all this time, but fo

  • RTSI meter / NI6143

    Hello I want to connect the physical channel cnt0 to the rtsi port0. I tried to edit one of the examples using the DAQmxConnectTerms function, but only the 89137 error appeared: DAQmx error: specified route can not be satisfied, because it requires r

  • Why do I get ' Windows Live Mail error ID: ox8de2007 ".

    If I try to contact someone to a Web site. Live Mail won't send it. I get this error message

  • change the name of the user account

    When I set up my new HP Pavilion desktop computer a few months ago, the keyboard has failed. I typed a few keystrokes before you begin to answer. The problem I have is that the keys I typed have become my identity as a user account. If I go into user

  • Issue of "New folder" Windows Explorer (Ed Pro v.7)

    I'm not able to create a new folder in Explorer wNewindows. The "New folder" button does not respond. (Win 7 Pro Ed)