Schema import Gets the foreign key number

Hi all;


Scott has a table named rank-> he has primary key-> different tablespace

Sharma has a table named emp-> he has foreign key-> different tablespace

$ imp/System Manager queue = refresh_sharma.dmp log = refresh_sharma_imp.log fromuser = touser = sharma sharma

Import: Free 11.2.0.1.0 - Production Thursday, may 7, 18:35:03-2015

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT: V11.02.00 direct

import in US7ASCII and AL16UTF16 NCHAR character set

import server uses WE8MSWIN1252 (possible character set conversion) character set

Customer export uses the (possible character set conversion) WE8MSWIN1252 character set

. import of objects in SHARMA SHARMA

. . import of partition "CONT_EMP": "P1" 4000 imported lines

. . import of partition "CONT_EMP": "P2" 5000 imported lines

. . import of partition 'CONT_EMP': 'P3' 5000 imported lines

. . "DEPT" table import 12 lines imported

. . import of table 'EMP' 68278 imported lines

. . importing table "EMP_AUDIT" 4 imported lines

. . table 'Method' import 68000 lines imported

. . importing table "EMP_PERS_INFO" 68278 imported lines

. . importing table "EMP_PROJ_INFO" 68278 imported lines

. . table 'LOGTAB' import 603 lines imported

. . table import "PAYROLL" 186282 imported lines

. . import of table 'of the PROJECT"22 rows imported

. . importation of "TAB1" 4000000 imported table rows

. . table import 'TRANSPORT' 0 rows imported

IMP-00017: statement failed with error ORACLE 1031:

'ALTER TABLE 'EMP' ADD 'EMP_EMPLEV_C12_FK' OF CONSTRAINT FOREIGN KEY ("EMP_LEVE" '.

""L") REFERS TO"SCOTT" CATEGORY"("GRADE_NAME") ENABLE NOVALIDATE.

IMP-00003: ORACLE error 1031

ORA-01031: insufficient privileges

About to activate the constraints...

IMP-00017: statement failed with error ORACLE 2430:

' ALTER TABLE 'EMP' ENABLE CONSTRAINT "EMP_EMPLEV_C12_FK"

Import completed successfully with warnings.

30, 31 line number is display error.

'ALTER TABLE 'EMP' ADD 'EMP_EMPLEV_C12_FK' OF CONSTRAINT FOREIGN KEY ("EMP_LEVE" '.

""L") REFERS TO"SCOTT" CATEGORY"("GRADE_NAME") ENABLE NOVALIDATE.

After the import operation, to recreate the foreign key is the right option. but

By performing the import operation, how can all I avoid this error dump file or log file?

I don't want to use constraints = N.


Thanks in advance


You gave * of * SCOTT * at * SHARMA.  The grant received by SHARMA not getting exported when you export SHARMA.  So, it is not imported when you import SHARMA.  If you did an export and import of SCOTT before SHARMA, the award of the cross-schema would have also been imported.  (Subsidies granted by a user are exported with the user, the subsidies received by a user are not exported with the user).

Hemant K Collette

Tags: Database

Similar Questions

  • How can I get the data in the foreign key?  PHP/mysql

    I managed to create registration, log-in and results pages appear for accounts of client with PHP/Mysql/Dreamweaver 8. I have another page for more information to be contained in a child table, I used the Insert Wizard to create. I can't make it work. I get either a foreign key cannot be null error or a foreign key constraint.

    If I include the foreign key in the form on the page, I can manually enter the appropriate identification number, and it works. How to automatically enter the id into the foreign key column?

    I got the authentication of users using e-mail, password and user type.

    Thanks for your help

    When someone connects, Dreamweaver creates a session variable called $_SESSION ['MM_Username"]. Use this session variable to create a recordset object to get the ID of the user, who can then be entered in the child table's foreign key field.

    Dreamweaver automatically updates the code for recordsets immediately above the DOCTYPE declaration, then you will need to move above the code for the server behavior insert record. So it must be in the following order:

    1. Recordset to get the user ID
    2. Insert the record to the child table
  • Add the foreign key refers to a different schema

    Hello

    We have a database with schemaA and schemaB and we use a data model for schemaA with SQL Data Modeler.

    Our data model is based on SchemaA and we do not want add schemaB or create subview in our current model for schemaB since our dev team do not want schemaB in the model

    We have created a synonym in tableB schemaB shcemaA after granting select them, references to schemaA

    We have added a foreign key on tableA in referencing TableB on schemaB schemaA.

    for example. Add ALTER table tableA foreign constraint key(column-name) references tableB(colum-name)

    So far so good.

    But if we try to produce the DDL for tableA it has not provided the ALTAR of the foreign key that is based on shcmeaB

    We know that we cannot add foreign key on dblinks.

    How can I get the Modeler DDL from SQL data for tableA, including the foreign key

    We appreciate the answers

    Kind regards

    Zafar

    Hi zak,.

    We have created a synonym in tableB schemaB shcemaA after granting select them, references to schemaA

    We have added a foreign key on tableA in referencing TableB on schemaB schemaA.

    You can do it in the database because TableB exists in the database and DB knows its definition, including the existing constraint of PK/UK.

    This is the same model of data Modeler - you must have the definition of the table referenced in order to create the FK that refer to the constraint of PK/UK.

    As it works now (we can change it) you can have modeled for SchemaA and ModelB for SchemaB. Then, you can drag & drop tableB form the Navigator to the diagram of the ModelA and TableB there will exist as an object remote read-only, you can use to create the FK.

    With the help of subviews, DDL generation and configurations of reports, you can display the dev team than objects that they want to see - on the charts in generated DDL and reports.

    Philippe

  • SQL statement error INSERT The conflicted with the FOREIGN KEY constraint

    I recently installed a reporting for vmware vsphere software, but I get a SQL error. I opened a request for assistance with vmware, but so far they have not come up with a solution. The error is caused by: com.microsoft.sqlserver.jdbc.SQLServerException: instruction INSERT The conflicted with the FOREIGN KEY constraint 'FK_CB_VSM_NETWORK_VC_ID '. The conflict occurred in database 'VCChargebackVCC02', table "dbo." " CB_VSM_SERVER', column 'VC_ID '. I don't know a lot about SQL, so I'm lost in the extent of troubleshooting is concerned. If anyone has any ideas I'd love to hear them.

    SQL questions are better posed on Technet.  They are better equipped to manage the

    http://social.technet.Microsoft.com/forums/en-us/categories/

  • When you try to update Windows XP, I get the message: error number: 0 x 80245001

    When you try to update Windows XP, I get the message: error number: 0 x 80245001

    Hello

    If you have configured the installation of the automatic update of your computer, the computer downloads the files necessary for the installation of Windows updates in the background and records them in certain folders on your computer. During installation, these downloaded files are extracted by the requirement by the services of update running on the computer.

    The error you are getting means that some of these extracted files required by Windows Update have been damaged. Now, in order to solve the problem better, we need more information about the computer that has the problem. José asked a few questions about this computer in the first reply to your message, it will be very useful if you could answer these questions.

    Here is some important information that we need:

    1. What is the level of service pack installed on your computer?
    (Click the Start button, click run, type winver, and press Enter to know that information)

    2. what update failed to install with this particular error code?
    (Please refer to the method 1: search for the installation error code in the Windows Update troubleshooting tool section of this article to learn how to check your update history to find this information)

    In the meantime, you can follow these steps on the computer and see if that helps:

    Note: These steps will give the files associated with Windows Update in your computer. Perform these steps would be clear Windows Update history on the computer.

    1. click on Start, click run , and then type Services.msc in the run box and press ENTER. This should open the windows of Services for you.

    2. then find the following three services in the list of Services and stop them (by clicking on it and click on stop) one by one:

    Automatic update service

    (BITS) Background Intelligent Transfer Service

    Cryptographic services

    3. open Windows Explorer and navigate to the following location:

    C:\Windows\

    Rename the folder C:\Windows\SoftwareDistribution in SoftwareDistribution.old

    4. go to the following location:

    C:\Windows\System32\

    Rename the Catroot2 in Catroot2.old folder

    (be careful here, do not rename the C:\windows\system32\catroot folder, you must rename the Catroot2 folder only)

    5. now go back to the Services window and start the services of three you had stopped earlier.

    Now, close all open windows, restart the computer and try updates and install them. If it fails again, please answer with the information that we requested.

    I hope that the information I provide here helps you. If you still need assistance, we know. We are happy to be of assistance.

  • Get the product key of product ID__Install some other DVD Vista and put my key in it__

    I bought a new Compaq laptop with Vista Home basic pre installed and a sticker stating my laptop product key. After a week or disc hard crashed and was replaced. Now it had Vista Business installed (everything else looked like exactly the same 60-day trial of MS office, Norton Internet Security etc.). I checked with MS real profit and he says, AUTHENTIC, and if I didn't mind. Now the problem is that I don't have the product key for vista professional. I have the product ID(it is shown is My Computer-->properties). How can I get the product key? I used 2 different 3rd party tools that ask you to provide keys for all installed microsoft software, and both of them give me the same key, do I count on it?

    I recently got win7 32 bit professional, MSDN key (free student edition). I want to give it a try. But I want to make sure I can get back to Vista again in case I have no problem. I have the recovery disk (I did once I had Vista Business), but I don't want to format all disks, and in this case, the recovery disk is of no use. How can I get a drive in Vista Business? If I borrow from a friend with a Dell laptop, it'll work if I install and then change the product key?

    To restore Vista using Ghost 15 you first restore the system reserved partition (only if it has been damaged or deleted) everything else you need to do is to restore the second file.

    But the system, reserved and the Vista partition should be part of (included) in the Image backup that you create. This first file / partition image is important and takes very little space (about 200 MB). His retirement Partition Vista takes the largest part of your space on the backup drive.

    To answer your question, yes you choose selectively to only save the Vista partition.

    JS
    http://www.PAGESTART.com

    Never be afraid to ask. This forum has some of the best people in the world to help.

  • I have the product key number I purchased through the Express upgrade. Is there a link for the download of Windows 7 professional free?

    I bought Windows 7 Professional upgrade through Express during which I contain the product key number... It seems to me not to be able to communicate with them? I need to re - install windows 7 and need a download for professional during which I contain the number of product for a 64-bit key.

    NO MATTER WHAT DIRECTION WILL BE APPRECIATE

    Kevoogle

    Alessandri keV

    Discussions were merged.

    Deleted duplicate.

    You cannot use a Windows 7 Professional anytime upgrade product key with reinstall media, it can be used only to upgrade license of qualification basis where you bought the upgrade in the first place (Starter, Home Premium).

    The first thing you need to do is to get your key to Windows 7 Professional upgrade Express:
     
    An e-mail containing your product key will be sent to the e-mail address associated with your Windows Live ID account or e-mail address you provided if you ignored the account configuration. Note: If you use an email tool or spam blocker spam filter, be sure that you can receive e-mail messages from microsoft.com.
     
    What happens if I lose my product key?
     
    If you lose your product key, you can return to

    www.Windows7.com/GetKey and sign in using the "Sign In" link in the upper right of the page. This will allow to recover your product key if you have established your account with your Windows Live ID. If you do not configure a Windows Live ID account initially there is no record of your online product key. Check your e-mail since it is the only trace of your product key.
     
     
     
    or

    Here are four utilities, which can display your product keys if they are still there:
    Belarc Advisor: http://www.belarc.com/free_download.html
    (He did a good job of providing a wealth of information.)
     
    Also: http://www.magicaljellybean.com/keyfinder.shtml
    and: http://www.nirsoft.net/utils/product_cd_key_viewer.html
    and RockXP: http://www.majorgeeks.com/download4138.html which has additional features.
     
    --------------------
     
    The next thing you need to do is to ensure that your data is backed up:
     
    http://notebooks.com/2010/12/27/how-to-backup-to-an-external-hard-drive/
     http://notebooks.com/2011/02/25/how-to-restore-a-backup-from-an-external-hard-drive-in-Windows-7/
     
    -------------------
     
    The next thing you need to do is to reinstall the base license that you upgraded, Windows 7 Starter Edition or Home Premium.
     
    If your computer is pre-installed with Windows 7:

    New computers that come pre-installed with Windows often have what is called a recovery partition. This is used to reinstall an operating system in the case of a system failure. To access it, you need to start when you start your computer by pressing a function key. This can be either F1, F2, F9, F10, F11, F12 key DEL or tab. See the manual that came with your PC for instructions on how to reinstall Windows.

    If your recovery partition is not available or damaged, you must contact the manufacturer of your computer, and request that a defined recovery disk you can use to reinstall Windows 7. They could practice a small shipping and handling.
    ------------------------------------
    This is how the recovery partition is accessible to most popular brands...
    For Dell, press F8 on the keyboard until the Advanced Boot Options menu appears on the screen.
    For HP, press F11 directly after switching on the device
    For LG, press F11 directly after switching on the device
    For Toshiba, press and hold "0" BEFORE and during the power upward
    For Acer, press and hold ALT + F10, as soon as you see the logo
    For Asus, press F9, as soon as you see the Asus logo.
    For Samsung, press F4 to the power upward...
    For Fujitsu, press the F8 key directly after the power
    Advent, restart your computer. Then, press F10 repeatedly until the message "Starting system recovery"
    Sony VAIO, reboot and press "F8" or "F10" repeatedly until the screen "Advanced Boot Options".

    ------------------------
     
    If it was a store bought retail license:
     
    http://Windows.Microsoft.com/en-us/Windows7/installing-and-reinstalling-Windows-7
     
     
     
    --------------------
     
    After you have reinstalled your original license, make sure that it is enabled before doing the upgrade to Windows 7 Professional:
     
    How to activate Windows 7 manually (activate by phone)
     
    1) click Start and in the search for box type: slui.exe 4
     
    (2) press the ENTER"" key.
     
    (3) select your "country" in the list.
     
    (4) choose the option "activate phone".
     
    (5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
     
    (6) explain your problem clearly to the support person.
     
     http://support.Microsoft.com/kb/950929/en-us

    ----------------------
     
    Redo the Express Upgrade:
     
    Click Start, type Anytime Upgrade, click on the option enter a key, enter the key of Windows 7 Professional on demand, click Next, wait while checking the key, accept the license agreement, click on upgrade, wait while the software upgrades, (it may take 10 minutes or more depending on the if updates are required) your computer restarts automatically, after the reboot, Windows 7 will notify you updating the computer, the computer will restart once more automatically and will be completed the upgrade, a window will appear notifying the upgrade was successful and your computer is ready to use, click Close, you should be upgraded to Windows 7 Professional your files, programs and settings retained.
     
     
     
    ---------------
     
    Go to reactivate the license again.

  • How can I make sure that changes in a primary key (in the parent table) would also appear directly in the FOREIGN KEY in the child table?

    Forgive my question. I am very new to Oracle.

    How can I make sure that changes in the key primary supplier_id (concerning the supplier table) would also appear directly in the FOREIGN KEY (supplier_id) in the products table?

    Is that not all the primary key and FOREIGN KEY on?

    My paintings:

    I created 2 tables and connect to apply in the data base referential integrity, as I learned.

    CREATE TABLE - parent provider

    (the numeric (10) of supplier_id not null,)

    supplier_name varchar2 (50) not null,

    Contact_Name varchar2 (50).

    CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)

    );

    CREATE TABLE - child products

    (the numeric (10) of product_id not null,)

    supplier_id numeric (10) not null,

    CONSTRAINT fk_supplier

    FOREIGN KEY (supplier_id)

    REFERENCES beg (supplier_id)

    );

    I inserted the following text:

    INSERT INTO provider

    (supplier_id, supplier_name, contact_name)

    VALUES

    (5000, 'Apple', 'first name');

    I expect that the supplier_id (5000) to the provider of the table also appears in the products table under key supplier_id having the same value which is 5000. But this does not happen.

    How to get there?

    Thanks in advance!

    Hello

    What is a foreign key in Oracle?

    A foreign key is a way to ensure referential integrity in your Oracle database. A foreign key means that the values of a table must appear also in another table.

    Ok!??

    What is now the right way to implement referential integrity in your Oracle database that the values of a table must also be included in another table?

    A foreign key referential integrity indeed enfore in ensuring that the value in the child table must have a corresponding parent key (otherwise you will encounter an error, as evidenced by "SomeoneElse"). However, it will never automatically insert a row in the other table.

    If you are looking for a solution that automatically inserts a record in the other table, maybe you should go for triggers:

    See:

  • I just got a new Macbook Pro when I reinstall my CS4 Master Collection everything works fine, but I can't get Acrobat 9 pro to get the serial key

    I just got a new Macbook Pro when I reinstall my CS4 Master Collection everything works fine, but I can't get Acrobat 9 pro to get the serial key

    OK, it worked. Someone suggested dismantling drives all connected. In fact, no luck. But while all the disks were taken out and closed all applications I uninstalled Acrobat Pro using the application in the folder Acrobat Pro. Then I went back to the installer and have already told him only to install Acrobat Pro. Once done everything first, I opened Acrobat Pro. He asked to install some extras and I said no a few times. It opened and worked on a test pdf. With her still open I tried to open Acrobat Distiller. He did not ask a serial number, but I wanted to just install an extra. I said no again and it finished opening. Wanted to be my default PDF application but an extract which is better so I said, person not the last time. He has worked to create a perfect pdf of an Illustrator EPS. Hope this works for you also.

  • Optimize the foreign key for the removal of the cascade constraint.

    Hello

    JDeveloper version: 11.1.2.3.0

    I saw this blog and found something new to me: http://snag.gy/qI6dY.jpg

    Jdeveloper user interface, there is an option to select all tables to select the foreign key and set it for the removal of the waterfall.

    My project is deployed on multiple databases. I wonder where this change is registered. None of the project files is modified.

    Can I make this change (from limitations to the waterfall) for each database that I use?

    Here is the blog where I saw that: http://tompeez.wordpress.com/2013/04/22/master-detail-insertdelete-sample/

    I have my object associations optimized for the removal of the waterfall, but without the option above together, I always get constraint violations...

    Concerning

    Not sure however if you set the option the DOF looks like

    "EMP_JOB_FK' FOREIGN KEY ('JOB_ID') CONSTRAINT
    REFERENCES 'HR '. "" SELECT JOBS "("JOB_ID') WE DELETE CASCADE

    If you set the option to cascade for fk Job_id from the employees table.

    Timo

  • Drop partition without disabling the foreign key

    Hi all

    I have a table parent and child.

    Parent table

    create the table parent_1
    (identification number,
    create_date date,
    Constraint parent_1_pk001 PRIMARY KEY (id))
    PARTITION OF RANGE (create_date)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
    (PARTITION parent_1_part VALUES LESS THAN (January 1, 2010 '));

    Child table
    create the table child_1
    (identification number,
    create_date date,
    Constraint child_1_fk001 FOREIGN KEY (id)
    REFERENCES parent_1 (id))
    PARTITION OF RANGE (create_date)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
    (PARTITION create_date_part VALUES LESS THAN (January 1, 2010 '));


    I have problems to delete partition.
    Parent_1
    1 JULY 26, 12
    2 JULY 26, 12

    Child_1
    1 JULY 26, 12

    ALTER drop partition table CHILD_1 SYS_P274;
    table altered CHILD_1.

    ON THE PARENT PARTITION A FALL
    ALTER drop partition table parent_1 SYS_P273;

    Error report:
    SQL error: ORA-02266: unique/primary keys in table referenced by foreign keys enabled
    02266 00000 - "unique/primary keys in table referenced by foreign keys enabled.
    * Cause: An attempt was made to truncate a single table or
    primary keys referenced by foreign keys in another table.
    Other unauthorized trades are a drop/truncate partition a
    partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    * Action: Before performing the operations described above, the table, disable the
    constraints foreign key in other tables. You can see what
    constraints are making reference to a table by issuing the following
    command:
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'tabnam ';


    PLEASE KNOW IF THERE IS A WAY TO THE PARENT PARTITION DROP WITHOUT TOGGLE FOREIGN CONSTRAINTS


    Thank you
    SQL Error: ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    02266. 00000 - "unique/primary keys in table referenced by enabled foreign keys"
    *Cause: An attempt was made to truncate a table with unique or
    primary keys referenced by foreign keys enabled in another table.
    Other operations not allowed are dropping/truncating a partition of a
    partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    *Action: Before performing the above operations the table, disable the
    foreign key constraints in other tables. 
    

    You can do until you disable the foreign key constraint

    http://jonathanlewis.WordPress.com/2006/12/10/drop-parent-partition/

    Hope this helps

    Mohamed Houri
    www.hourim.WordPress.com

  • Identify the foreign key table

    I have a table that has a few constraints that are foreign keys to other tables (see column FK_ETHNIC below). My naming conventions are consistent so they all start with 'FK_ ". In SQL, how can I find the table that the foreign key column references? I have a process that must find this table and then get all of its columns.
    Thank you!

    CREATE TABLE STU_BASE
    (PK_ID VARCHAR2 (32), sys_guid() by default)
    CONSTRAINT pk_stu_base
    KEY ELEMENTARY SCHOOL
    With the HELP of INDEX TABLESPACE sis_express_index
    STORAGE (INITIAL 524288
    NEXT 524288
    PCTINCREASE 0),.
    STUDENT_ID VARCHAR2 (15).
    Fk_stu_base_ethnic FK_ETHNIC VARCHAR2 (32) CONSTRAINT
    REFERENCES
    Ethnic (PK_ID)
    REMOVE THE NULL VALUE;

    CREATE TABLE ETHNIC
    (PK_ID VARCHAR2 (32), sys_guid() by default)
    CONSTRAINT pk_ethnic
    KEY ELEMENTARY SCHOOL
    With the HELP of INDEX TABLESPACE sis_express_index
    STORAGE (4096 INITIAL
    NEXT 4096
    PCTINCREASE 0),.
    VARCHAR2 (2) ETHNIC,.
    ETHNIC_DESC VARCHAR2 (30),
    STATE_CODE VARCHAR2 (2),
    FEDERAL_CODE VARCHAR2 (2))

    You could do a self-join with CONSTRAINTS (USER, ALL, s/n) views. You can search a constrainttype of 'R' and you can attach it to itself based on the R_OWNER and R_CONSTRAINT_NAME columns.

    For example:

    SELECT r1.owner      AS child_owner
         , r1.table_name AS child_table
         , r2.owner      AS parent_owner
         , r2.table_name AS parent_table
    FROM   all_constraints r1
    JOIN   all_constraints r2 ON  r2.owner           = r1.r_owner
                              AND r2.constraint_name = r1.r_constraint_name
    WHERE  r1.constraint_type = 'R'
    ;
    

    Published by: Centinul on February 16, 2012 15:36

  • Please, I have the following question on the foreign key and the ora-00904

    Thanks in advance!

    I created the table:

    Create the Department table
    (
    DNAME varchar (15) NOT NULL,
    deptID number (5) NOT NULL,
    Primary key (dname, deptid)
    )

    then...

    Create table Manager
    (
    MgrID number (10) not null,
    Not null, name varchar (10)
    Start_date date not null,
    Primary key (mgrid),

    CONSTRAINT fk_department
    FOREIGN KEY (dname, deptip)
    Department of REFERENCES (dname, deptid)
    )

    Trying to create the table with the constraint, it yeilds one:

    ORA-00904: "DNAME": invalid identifier
    +.. .with an asterisk under "dname" in line: FOREIGN KEY (dname, deptip) +.

    I tried joining my name of the column with quotation marks ("" "); capitalized for consistency; and we tried creating and editing then - all to nothing will do. I also tried to use the user interface with Oracle Express Edition and the moment where I click on create, the same error appears. Could someone help please straighten out me up - was this threat for four days.

    Thanks again!

    Hello

    Welcome to the forum!

    Columns that will reference the other table must be declared just like all the other columns; including the names in a FOREIGN KEY constraint is not auotmatically define them.
    It works:

    CREATE TABLE Manager
    (       mgrid          NUMBER (10)     NOT NULL,
         Name          VARCHAR (10)     NOT NULL,
         Start_date      DATE          NOT NULL,
         dname          VARCHAR2 (15),               -- New
         deptid          NUMBER (5),               -- New
    PRIMARY KEY (mgrid),
         --
    CONSTRAINT fk_department
    FOREIGN KEY           (dname, deptid)
    REFERENCES department (dname, deptid)
    );
    

    (assuming that the departments table, you posted, there).

    Is there a reason why you use VARCHAR instead of VARCHAR2?

    In the departments table, do you really need both dname and deptid in the primary key? For example, if you have a line with name = "ACCOUNTING" and deptid = 10; is it possible that you could have another line with deptid = 10 and some different dname, say 'REASEARCH '? It is more common to only have a deptid as primary key and have columns in the foreign key constraints that reference.

  • How did the foreign key that is recognized by the primary key

    Hi, when I have two user tables and userLevel and the primary key of the user is the user name and I add a field to userLevel userID is only to make the userID field in userLevel automatically the foreign key of the table? Or do you switch the engine of MyISAM tables to InnoDB to make relational links. Can someone please explain this in English clear to me, because I just can't get my head around this.

    In the case of a query such as SELECT statement, we talked, being a key actually means that the field is indexed so that the database can quickly look up.  Thus, in phpMyAdmin, you set the field to be indexed by the visualization of the structure of the table and clicking the icon index (the one with the Lightning) for the field in the Action section.

    If you are looking for integrity refrential between tables we also talked about and using the InnoDB engine, you can click the link 'Show the relational' in the table structure page of phpMyAdmin and define foreign key constraints.

  • will be the foreign key allows Null values?

    Hello gurus!


    will be the foreign key allows Null values?


    Thanks in advance!

    Yes

    You can try example below

    create table table_1(id number primary key)
    insert into table_1 values (1);
    create table table_2 (id number references table_1(id),name varchar2(10))
    insert into table_2 values (null,'test')
    commit;
    

Maybe you are looking for