Lack of Primary and Foreign Keys and Efficiency

I am reverse engineering a Maximo database. I am shock that it does not have Primary or foreign keys define for 590 out of 620 tables.
My question is does the lack of Primary and Foreign key relationships adversely impact the efficiency of an Oracle database? I think it does IBM techs do not think it does.
Anyone has the answer?

does the lack of Primary and Foreign key relationships adversely impact the efficiency of an Oracle database? Not necessarily. There are many large OLTP databases that do not define PKs and FKs.
It is true that the presence of constraint defintions is used by the optimizer. However,
what matters is how the application is written and how the optimizer handles it.
Remember that Oracle Databases have been in production since before constraint definitions were introduced.
Hemant K Chitale
Edited by: Hemant K Chitale on Jun 9, 2010 10:05 AM

Similar Messages

  • Primary Key and Foreign Key Constraints

    Hi All,
    I would like to know PRIMARY KEY and FOREIGN KEY constraints on existing oracle tables. Could any one suggest me how to find out.
    Thanks,
    RED

    You can query DBA_CONSTRAINTS to get a list of all the constraints on table A and/or table B. The documentation I linked to gives a full list of the data you can see in DBA_CONSTRAINTS, but it includes things like the referenced table name and referenced constraint name for a foreign key constraint. If A is a parent of B or B is a parent of A, you could match up the parent's primary key constraint to the child's foreign key constraint.
    More generally, though, if you don't know that one of the tables is a parent of the other, figuring out how to join the two tables is probably not something that can be done using just the Oracle data dictionary. You would probably need an understanding of the data model being used to figure out what intermediate table(s) needed to be joined in order to relate rows in A to rows in B.
    Justin

  • Primary key and Foreign key on same column

    Hi, I am able to create below tables , primary and foreign keys as below.
    But Is this valid design? Can I define a column (ckey2 in table "child") as
    primary key and as well as foreign key?
    CREATE TABLE parent (
    col1 NUMBER,
    col2 NUMBER
    CREATE TABLE child (
    ckey1 NUMBER,
    ckey2 NUMBER,
    ckey3 NUMBER
    alter table parent add constraint parent_pk primary key( col1 );
    alter table child add constraint child_pk primary key( ckey2 );
    alter table child add constraint child_fk foreign key( ckey2 ) references parent( col1);
    Thanks.

    Can I define a column (ckey2 in table "child") as primary key and as well as foreign key?You mean you want to define a one-to-one relationship between parent and child tables.. why would you want to do that ? You might as well merge the 2 tables into one.

  • How to transfer database table contain null values, primary key, and foreign key to the another database in same server. using INSERT method.

    how to transfer database table contain null values, primary key, and foreign key to the another database in same server. using INSERT method.  thanks

    INSERT targetdb.dbo.tbl (col1, col2, col3, ...)
       SELECT col1, col2, col3, ...
       FROM   sourcedb.dbo.tbl
    Or what is your question really about? Since you talke about foreign keys etc, I suspect that you want to transfer the entire table definition, but you cannot do that with an INSERT statement.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Lost about 60-75% of my primary and foreign keys when Migrating from SQL Server 7

    Hi All,
    I did an almost successful migration between SQL Server 7.0 and Oracle9i.
    What happened:
    I seem to have lost my primary and foreign keys in the migration. The funny thing is when I viewed the constraints and indexes in Toad, they were there. However when I tried to enabled those constraints nothing happened.
    I really don't know how I can fixed this, but I don't understand why I didn't get a warning or an error message in the Migration Workbench (latest version).
    I did ignore the following errors, could that have anything to do with the keys being lost.
    Failed to create User:omwb_emulation; ORA-1920: user name "OMWB_EMULATION" conflicts with another user or role name
    Failed to create User:guest;ORA-01920: user name "GUEST" conflicts with another user or role name
    These users do not own any objects therefore I ignored them.
    Please advise
    Thanks

    Hi Joe,
    Not sure why you are able to see these objects and yet not able to enable them. Did you encounter any errors during the create Oracle Model phase?? Did you encounter any errors during the final Migrate phase?
    Also, it is really important to have a tablespace created before an attempt is made to create tables and indexes in the destination Oracle database.
    Regards
    John

  • Primary and Foreign Keys

    I've attempted to identify a primary and foreign key in these two tables, but I am getting a bunch of errors re duplicate keys and column names needing to be unique. Can someone explain to me what I am doing wrong? I have watched numerous tutorials. Perhaps
    the primary and foreign key I have identified don't meet the criteria?
    CREATE TABLE StockNames
    -- Added Primary key to [stock_symbol]
    [stock_symbol] VARCHAR(5) NOT NULL CONSTRAINT PK_stock_symbol PRIMARY KEY,
    [stock_name] VARCHAR(150) NOT NULL,
    [stock_exchange] VARCHAR(50) NOT NULL,
    GO
    stock_symbol stock_name stock_exchange
    AEA American External Accessories NYSE
    ASP All Sports Portal NYSE
    AIT Anthony Interest Technology NYSE
    ATV American Technology Vehicles NYSE
    ACM Anderson Charles and Mitchell NYSE
    ACH American Career Helpers NYSE
    AVA Alleviate America NYSE
    and the second table
    CREATE TABLE DailyPricesA (
    [stock_symbol] VARCHAR (5) NOT NULL CONSTRAINT FK_stocksymbol REFERENCES [StockNames]([stock_symbol]),
    [date] VARCHAR (15) NOT NULL,
    [stock_price_open] FLOAT (53) NOT NULL,
    [stock_price_high] FLOAT (53) NOT NULL,
    [stock_price_low] FLOAT (53) NOT NULL,
    [stock_price_close] FLOAT (53) NOT NULL,
    [stock_volume] INT NOT NULL,
    [stock_price_adj_close] FLOAT (53) NOT NULL,
    stock_exchange stock_symbol date stock_price_open stock_price_high stock_price_low stock_price_close stock_volume stock_price_adj_close
    NYSE AEA 8/02/2010 4.42 4.42 4.21 4.24 205500 4.24
    NYSE AEA 5/02/2010 4.42 4.54 4.22 4.41 194300 4.41
    NYSE AEA 4/02/2010 4.55 4.69 4.39 4.42 233800 4.42

    Hi Stan,
    I have removed "stock_exchange" - that removed that error. These are the other errors I am experiencing:Msg
    2714, Level 16, State 6, Line 8
    There is already an object named 'DailyPricesA' in the database.
    Msg 2714, Level 16, State 6, Line 36
    There is already an object named 'StockNames' in the database.
    Msg 2627, Level 14, State 1, Line 47
    Violation of PRIMARY KEY constraint 'PK__StockNam__117C59C768B2BB7F'. Cannot insert duplicate key in object 'dbo.StockNames'. The duplicate key value is (AA).
    The statement has been terminated.
    Msg 1913, Level 16, State 1, Line 54
    The operation failed because an index or statistics with name 'SNIndex' already exists on table 'DailyPricesA'.
    And the code:
    USE NYSEDatabaseProject
    -- Drop the table to clean up database.
    --DROP TABLE DailyPricesA
    --GO
    -- Create the table.
    CREATE TABLE DailyPricesA (
    [stock_symbol] VARCHAR (5) NOT NULL CONSTRAINT FK_stocksymbol REFERENCES [StockNames]([stock_symbol]),
    [date] VARCHAR (15) NOT NULL,
    [stock_price_open] FLOAT (53) NOT NULL,
    [stock_price_high] FLOAT (53) NOT NULL,
    [stock_price_low] FLOAT (53) NOT NULL,
    [stock_price_close] FLOAT (53) NOT NULL,
    [stock_volume] INT NOT NULL,
    [stock_price_adj_close] FLOAT (53) NOT NULL,
    -- Add a foreign key.
    -- [stock_symbol] VARCHAR (5) NOT NULL CONSTRAINT FK_stocksymbol REFERENCES [StockNames]([stock_symbol]),
    BULK INSERT DailyPricesA
    from 'C:\Users\fenwky\NYSE_daily_prices_A.csv'
    -- firstrow = 2 skips the header row, field terminator =',' deterines the separator, and rowterminator defines where the row ends
    with (firstrow = 2, fieldterminator = ',', rowterminator = '\n')
    GO
    -- Create an index named DPAIndex, for the columns stock_symbol//'DPAIndex' already exists on table 'DailyPricesA'
    --CREATE INDEX DPAIndex
    --ON DailyPricesA (stock_symbol);
    -- Drop the table to clean up database.
    -- DROP TABLE StockNames
    -- GO
    CREATE TABLE StockNames
    -- Added Primary key to [stock_symbol]
    [stock_symbol] VARCHAR(5) NOT NULL CONSTRAINT PK_stock_symbol PRIMARY KEY,
    [stock_name] VARCHAR(150) NOT NULL,
    [stock_exchange] VARCHAR(50) NOT NULL,
    GO
    -- Insert the CSV into the table named Stocknames
    BULK INSERT StockNames
    from 'C:\Users\fenwky\NYSE_stock_names.csv'
    -- firstrow = 2 skips the header row, field terminator =',' deterines the separator, and rowterminator defines where the row ends
    with (firstrow = 2, fieldterminator = ',', rowterminator = '\n')
    GO
    -- Create an index named SNIndex, for the columns stock_symbol and stock_exchange.
    CREATE INDEX SNIndex
    ON DailyPricesA (stock_symbol);
    -- Select all from DailyPricesA
    select * from StockNames

  • Drop foreign keys and recreate foreign keys with on delete cascade dymanica

    I need to drop foreign keys and recreate foreign keys with on delete cascade dymanically via a script. Does anyone have a script available?

    You could also disable the integrity contraints.
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SET PAUSE OFF
    -- create a disable script
    SPOOL do_disable.sql
    SELECT 'ALTER TABLE '
           || table_name
            || chr(10) ||
           'DISABLE CONSTRAINT '
            || constraint_name
            || ';'
      FROM user_constraints
    WHERE constraint_type = 'R'
       AND status = 'ENABLED'
    select 'alter trigger '
           || trigger_name
            || ' disable;'
      from user_triggers
    where status = 'ENABLED'
    SPOOL OFF
    -- now create a enable script as well
    SPOOL do_enable.sql
    SELECT 'ALTER TABLE '
           || table_name
            || chr(10)
            || 'ENABLE CONSTRAINT '
            || constraint_name
            || ';'
      FROM user_constraints
    WHERE constraint_type = 'R'
       AND status = 'ENABLED'
    SELECT 'ALTER trigger '
           || trigger_name
            || ' ENABLE;'
      FROM user_triggers
    WHERE status = 'ENABLED'
    SPOOL OFF
    SET FEEDBACK ONif you run this script on a TESTdatabase you will end up with a do_disable.sql and a do_enable.sql script on youre local directory.
    Running do disable will disable all the currently enabled triggers and contraints.
    Running do_enable.sql will enable the previously disables triggers and contraints.
    be sure to test before executing this on a real live production database.
    Make sure you have a good backup!

  • My I Mac does not start properly without pressing option and apple keys ,and it freezes

    My I Mac does not start properly without pressing option and apple keys ,and it freezes

    Try any of the following:
    http://support.apple.com/kb/HT1379 Resetting your Mac's PRAM and NVRAM  
    Disconnect all devices from the computer then do the following:
    Boot up from your Snow Leopard Install DVD while holding down the "c" key.
    Select the language you wish to use, and then choose "Disk Utility" from the menu bar.
    Your HD should appear in a panel on the left hand side of the window which opens. Select it and then click on the "repair disk" button in the right hand section of the window.
    Once this process has been completed restart your computer and repair permissions directly from Disk Utility.
    If Disk Utility is unable to complete the repair, you will need to use a stronger 3rd party utility like DiskWarrior, Techtool PRO (not Deluxe) or Drive Genius.
    Troubleshoot the spinning beach ball/freezing & crashing 

  • Brand new 15" MacBook Pro Retina - unplugged from Thunderbolt Display and Keyboards today find keyboard alpha-numerics not working; except the function keys, delete key, tab key, command/ctrl/shift/alt/fn and arrow keys; and 7/8/9/u/o/j/l nudge cursor

    Brand new 15" MacBook Pro Retina - unplugged from Thunderbolt Display and Keyboards today find keyboard alpha-numerics not working; except the function keys, delete key, tab key, command/ctrl/shift/alt/fn and arrow keys; and 7/8/9/u/o/j/l produce cursor nudges.

    It's a new machine - and the Thunderbolt Display is meant to work with it. You need to just make an appointment at your local Apple Store and have them fix whatever is wrong.
    If you like, you could always try a SMC reset and a PRAM/NVRAM reset to see if either of those will get your keyboard back in working order...
    Clinton

  • I am having troubles with 3 things: scrolling with my laptop mouse, controlling my laptops volume with F9 and F10 keys, and I can not copy and paste images.

    I am having troubles with 3 things: scrolling with my laptop mouse, controlling my laptops volume with F9 and F10 keys, and I can not copy and paste images.

    Hello,
    Try disabling graphics hardware acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.
    You might need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    Then perform these steps:
    *Click the orange Firefox button at the top left, then select the "Options" button, or, if there is no Firefox button at the top, go to Tools > Options.
    *In the Firefox options window click the ''Advanced'' tab, then select "General".
    *In the settings list, you should find the ''Use hardware acceleration when available'' checkbox. Uncheck this checkbox.
    *Now, restart Firefox and see if the problems persist.
    Additionally, please check for updates for your graphics driver by following the steps mentioned in the following Knowledge base articles:
    [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    [[Upgrade your graphics drivers to use hardware acceleration and WebGL]]
    volume controls issues are windows, not firefox.
    How your copy and paste your image? from where to where

  • My ipod touch would not go past the apple logo, it would just shut off. i held the power and home keys and connected to itunes

    my ipod touch would not go past the apple logo, it would just shut off. i held the power and home keys and connected to itunes but now its on the connect to itunes picture and shuts off on its own. even if i try and shut it off myself it won't. it only stays on for about 3-5 minutes:( please help!!!

    When it shows the Connect to iTunes screen and you connect it to iTunes, have you tried restoring it?
    This should solve your problem because the most common cause of your issue is a software glitch that is preventing your iPod from completing it's boot sequence. Restoring it will replace the software on the iPod with a fresh set so it can be used again.

  • Mapping in OWB with primary key and foreign key relationship

    Hi all,
    I am new to this datawarehousing field. I have just started my career. I have to now create a mapping in owb where a table has a field which is a primary key of another table in the same staging area. If you guys could help me out with the a method it can be created that would be very helpful to me.
    I thought of 2 ideas,
    1. If I can use a look up, but then I am not sure if i can use a lookup for primary key, foreign key relationship. If I can use also, I do not know how to use that.
    2. What if I can directly take that the first table and link the primary key of that table to the second table which uses that primary key of the first table as one of its fields.
    I do not know how feasible these methods are. Please guys help me out.
    Thanks in advance.

    I have a similar case where table a and table b having relation but table a got inserted with data and table b is empty so there no values for foriegn key column in table b to realte with table a.
    Now i want to load table b foriegn key with primary key column values of table a.
    how can we do this in owb
    thanks
    kumar

  • Oracle 9i primary and foreign key constraint

    I had created table in the following way
    create table dept(deptno number,dname varchar2(20));
    create table emp(empno number primary key,ename varchar2(25), deptno number references dept(deptno));
    One can get constraint name and constraint type from user_constraints table. But I want to know name of the column of table from which column is used as foreign key in another table. How to get such information?

    SQL> Select *From user_cons_columns  A
      2   Where Constraint_Name In (Select r_Constraint_Name
      3                           From User_Constraints B
      4        Where Table_Name='EMP'
      5          And Constraint_Type='R'
      6          Group By r_Constraint_Name
      7          )
      8  /
    OWNER                          CONSTRAINT_NAME                TABLE_NAME                     COLUMN_NAME                       
    SCOTT                          PK_DEPTNO                      DEPT                           DEPTNO                             Edited by: babaravi on Oct 5, 2009 3:34 PM

  • Primary keys and foreign keys

    Hi,
    is there a script available for changing the value of a primary key which automaticly
    detect all foreigs keys refering to this primary key and change them as well?
    William Oorschot

    I don't have the script now. but you can make a procedure of ur own.
    using a join on user_constraints, and user_cons_columns you can find out all the columns in all the tables which are referencing the particular primary key. once you have the table and the referencing columns, you can change the value of those columns with the new value.
    you'll have to call this procedure from a before row level trigger.
    HTH
    Naveen

  • Primary key and Foreign Key

    Hello,
             I have a question which was asked in an interview
    Can a Primary key in a table also act as a foreign key in the same table ?
    If yes than please provide a simple example
    Thanks
    www.techgulf.blogspot.com

    See this illustration
    create table t
    id int identity(1,1) not null primary key,
    val varchar(100)
    create table t2
    id int not null primary key,
    val varchar(100)
    -- make pk itself as fk to table t
    alter table t2 add constraint fk_t2 foreign key (id) references t(id)
    --some test values to t
    insert t (val)
    values ('test'),('test1'),('test2')
    -- populate t2 first two suceeds
    insert t2(id,val)
    values (1,'iuyi')
    insert t2(id,val)
    values (2,'ef24r')
    -- this will fail as we dont have record with id 4 in t
    insert t2(id,val)
    values (4,'weqw')
    --check the output
    select * from t
    select * from t2
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for

  • Multiple libraries on 1 computer, can't access new library

    I have two libraries on two computers, one on each. I needed to move one library to the computer that already has one library. I followed all the steps on the apple article "how to use our ipod to move your music to a new computer". Now both librarie

  • How can I add a picture to the Automator Action "Watermark PDF Documents.action"

    Looks like a bug: under 10.7.2 i cannot add a picture to the Automator Action "Watermark PDF Documents.action". Works perfectly under 10.6.8.

  • Drop down not working.. Module pool

    Hello, a simple one but irritating why it is not working please can any one help me..Drop down or f4 nothing is working.. TYPES : BEGIN OF TY_Tab,         TYP(8) TYPE C,        END OF TY_TRD. *DATA : T_Tab TYPE TABLE OF TY_Tab, *       W_Tab TYPE TY_

  • WRT54Gv3 Wireless bridge Problem

    I seem to be having an issue bridging my wireless router. I have high gain antennas installed and recently flashed to DD-WRT firmware. At first, no problem. Wireless and wired both worked. Then Wireless worked and i could get to settings with 192.168

  • Convert string to date for Ms Access

    I have some date in a textFile!!! I get them via Buffered and FileReader into my java application and put them into a Vector! Every date is formatted as Strings and I want to convert them into a date format(YYYYMMDD). The date are not used for " Syst