How to create a primary key or foreign key

in the table student, sid should be the primary key
in the table prerequisite cnum should be the foreign key and prereq the primary key
please help me with the syntax thanks.

As I said in your other post, it's all in the docs, go first to http://tahiti.oracle.com and try to find the answer yourself
http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/clauses3a.htm#1002630

Similar Messages

  • How to create one primary key for each vendor

    Hi all
    i am doing IDOC to jdbc scenario
    i am triggering idoc from R/3 and the data is going into DB table vendor through XI.
    structures are as follows:
    sender side: ZVendorIdoc (this is a customized IDOC , if i triger IDOC for multiple vendors then it triggers only 1 idoc with multiple segment )
    Receiver side:
    DT_testVendor
        Table
            tblVendor
                action UPDATE_INSERT
                access                     1:unbounded
                    cVendorName         1
                    cVendorCode        1
                    fromdate                1
                    todate                    1
                 Key1
                    cVendorName         1
    if i trigger idoc for multiple vendors ,for example vendor 2005,2006 and 2010 . then i can see that the only key comes from the very first field (2005) and the whole record for vendor 2005,2006 and 2010  goes into the table with this(2005) as a primary key
    now again if i send data for these three vendor 2005, 2006 , 2010, in which record for the vendor 2005 is same and for 2006 and 2010 are different than it takes 2005 as a primary key and it does not update the data in the table.
    my requirement is like this:   for each vendor there should be one unique key assigned.
                                              for above said example there should come three keys one for each vendor .
    could you please help me how to do this???????????

    Hi,
      In Mapping Make the statement is 0-unbounded.For each vendor create a statement.This will solve your problem.
    Regards,
    Prakasu.M

  • How to create a primary key

    Hello - New to Oracle and was wondering what is a good way to create an auto-incrementing primary key for a table. I have done this so far:
    Created a new sequence cst_swq begin with 1 increment by 1.
    CREATE OR REPLACE TRIGGER CST_TRIG
    BEFORE INSERT
    ON COOKIE_SALES
    REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
    SELECT CST_SEQ.nextval INTO NEW.SALE_ID FROM dual;
    This does not really work for me. Help with the code or a better idea to create primary key is much appreciated, thank you.

    adi26 wrote:
    This does not really work for me. What does that mean?
    In which way does this approch not meet your requirements?
    BTW: after 200+ posts you should have learned how to use tags...
    bye
    TPD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to create a primary key by 2 columns in sql??

    as title
    thx a lot.

    Chris,
    Well you have two basic ways. One is to issue an alter table command and define a PRIMARY KEY (also called a PK). The other is to create a UNIQUE index. The PRIMARY KEY creates an index anyway, though I prefer to just use unique indexes as you can specify more options in this manner. A table can only have 1 PK where as you can have multiple UNIQUE indexes. I also do not combine the PK definition directly into the CREATE TABLE command, as normally one would keep a seperate PK script, even if they did contain only unique indexes commands and not PK alter table commands.
    Anyway, below are the two methods of making a PK/Unique object for your table. The table name used here is T1 ...
    Method #1 (Primary Key)
    ALTER TABLE T1 DROP PRIMARY KEY;
    ALTER TABLE T1 ADD PRIMARY KEY
    (Column_1,Column_2, ...)
    STORAGE
         NEXT 512K
         MINEXTENTS 1
         MAXEXTENTS UNLIMITED
         PCTINCREASE 0
    Method #2 (preferred) : Unique Index
    DROP INDEX PK_T1;
    CREATE UNIQUE INDEX PK_T1 ON T1
    (Column_1,Column_2, ...)
    TABLESPACE INDX
    PCTFREE 10
    STORAGE
         INITIAL 1M
         NEXT 512K
         MINEXTENTS 1
         MAXEXTENTS UNLIMITED
         PCTINCREASE 0
    It's always best to define the storage clause for both the create table and it's indexes.
    Hope this helps ya,
    Tyler

  • Can I create constraints "Primary key - Foreign key" on materialized views?

    Hello!
    Can I create constraints "Primary key - Foreign key" on materialized views like on tables?
    My purpose - is to make DB schema "COPY" with set of materialized views or tables, which take data from time to time from other tables situated.into another schema "ORIGINAL".
    Also - I want to use reporting tool, like Crystal Reports, to make nice reports from schema "COPY". To make nice reports, I need primary-foreign relationships between materialized views or tables in schema "COPY".
    Is it possible to use materialized views?
    Or I should use only tables to get such result?
    Thank you in advance.
    Edited by: kogotok1 on Dec 3, 2010 5:01 PM

    What happens when you try it? Or search the manuals.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_6002.htm#i2105365
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm#REPLN360

  • How do I use Primary Key and RowID in Materialized View Logs and MVs

    How do I use Primary Key and RowID in Materialized View Logs and Materialized Views????
    I don’t understand in the Materalized View Logs the diference between Primary Key and RowID. Besides, I could choose both Primary Key and RowID.
    When I have to use RowID?? Why?? And Primary Key??? And both, Primary Key and RowID????
    Thank you very much!

    Yes, I have already read it...
    But for example I don’t Understand:
    This is the example 8-1
    CREATE MATERIALIZED VIEW LOG ON products
    WITH SEQUENCE, ROWID
    (prod_id, prod_name, prod_desc, prod_subcategory, prod_subcat_desc, prod_
    category, prod_cat_desc, prod_weight_class, prod_unit_of_measure, prod_pack_
    size, supplier_id, prod_status, prod_list_price, prod_min_price)
    INCLUDING NEW VALUES;
    But if I create a Materialized View with TOAD if I choose a KEY field I receive the error:
    ORA-12026: invalid filter column detected
    Then I have to take out the Key (in the above example prod_id)
    And then the script is
    CREATE MATERIALIZED VIEW LOG ON products
    WITH ROWID, SEQUENCE, PRIMARY KEY!!!!!!!!!!!!!!!!!!!!
    (prod_id, prod_name, prod_desc, prod_subcategory, prod_subcat_desc, prod_
    category, prod_cat_desc, prod_weight_class, prod_unit_of_measure, prod_pack_
    size, supplier_id, prod_status, prod_list_price, prod_min_price)
    INCLUDING NEW VALUES;
    I have PRIMARY KEY in the definition (I don’t choose it) and I don’t have the prod_id field
    Why is it????
    Note: If I execute the script to create the MV Log manually the PRIMARY KEY option NO IS in the script and the prod_id field either is in the script.
    And on the other hand,
    What is this:
    CREATE MATERIALIZED VIEW LOG ON sales
    WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON times
    WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON customers
    WITH ROWID;
    These MATERIALIZED VIEW LOG contain any fields????
    Or it contain the primary key fields of this tables (sales, times and customers)??? Then, Why is it ROWID instead of PRIMARY KEY????
    Thanks!

  • How to create a block key default for documents created by MIRO?

    Hi All,
    How to create a block key (BSEG-ZLSPR) default for documents created by MIRO?
    Could anyone tell me?
    Thanks
    Gandalf

    HI,
    The payment block--BSEG-ZLSPR can be made defaulted by two  ways.
    Means you want to fix one value all the times for the same ,you have to do the same in Vendor master
    ie in the Vendor Master in the Payment Transactions Selection screen. make the Payment Block you want to be defaulted in MIRO.
    you can do for all vendor master in mass change -- XK99.(LFB1)
    if you are not OK with the Above .then there is another way to do the same
    it is by Screen layout setting in SHD0
    in this enter the Transaction MIRO and create a Transaction variant Z*** and click on create
    and also create a Screen variant in OMLRLIST 
    T code MIRO
    Screen variant name Z**
    Program-SAPLFDCB
    Screen Number 0020
    and create it .
    in creating ---enter the default value in the Payment block and in the varinat just check the box w.content
    KNow in SHd0 add this screen variant for the above Trasaction variant
    and then activate this trasaction variant by going into the tab Standard variants.
    so that when ever you do miro this variant will be called and you can get this payment block defaulted.
    hope so it helps
    Regards
    Anjanna

  • Is it possible to create many primary key for a table?

    hello sir/mam.
    i am selva, i am new to abap,
    is it possible to create many primary key for a table?
    please guide me.

    Hi Selva,
    Many Primary Keys = Composite Key.
    i.e some set of columns will enable you to identify a unique row from a set of rows in the table.
    This can be achieved by checking the primary key check box in se11.
    Hope it helps.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • How to create a shortcut key for email ?

    how to create a short key on mac book pro

    You do not say what OS X you are running.  If it is 10.8.3 you simply can have Mail a 4-finger swipe away.
    No short key neccessary?
    If some earlier OS X see >System Preferences>Keyboard>KeyboardShortcuts>ApplicationsShortcuts

  • How to create a account key for application type M ?

    Hi Guys,
    How to create a account key for application type M ? and link the same with
    Gl account.
    thanks.

    Hi
    Please create the account keys or transaction keys in
    SPRO-> IMG-> MM-> Purchasing-> Conditions-> Define Price Determination Process-> Define Transaction/Event Keys
    Thanks & Regards
    Kishore

  • How i can Find primary key combination?

    Hi,
    I have small doubt how i can find primary key combination for a record in siebel application.( For example Opportunity list applet or Account list applet or etc.. what is the primary key combination and how i can find that combination for a particular record)
    Thanks & Regards

    Hi
    From the applet Identify the Business Component (BC)
    From the BC idnetify the table, and the property user key sesuence will give you the proper combination. Column conflic_id is used for handling remote synchronization.
    For BC based on S_PARTY, such as COntact, the table mentionned in User PRop will give your the main table used in this case.
    Best Regards
    EvtLogLvl

  • Creating a primary key with the parallel option and the tablespace option

    I know I can create a unique index with these options and then make the primary key with the "using index" clause. anyway to do this and skip the create unique index and just create the primary key ?

    SQL> ALTER TABLE t
      2  ADD CONSTRAINT pk_t
      3  PRIMARY KEY (testcol)
      4  USING INDEX
      5  TABLESPACE example
      6  PARALLEL (DEGREE 2);
    PARALLEL (DEGREE 2)
    ERROR at line 6:
    ORA-03001: unimplemented featureYou can name the tablespace but you must do an alter index thereafter.

  • How to create a unique key using two or more attributes?

    how to create a unique key using two or more attributes ?

    The following example illustrate how to create a unique key using two or more attributes/fields
    Scenario: Implementing Unique Key on ManagerID & Location ID in DepartmentEO(Department Table)
    Step#1: Open the Desired Entity Object “DepartmentEO”. Go to Overview tab & Click “General” Finger tab.
    Step#2: Expand “Alternate Keys” section & click “+”.
    Step#3: In the Pop-up wizard, Enter a name for alternate Key “Unique_Manager_X_Location”.
    Step#4: Select the desired attributes/fields from available list & Shuffle to right side.
    Step#5: Now go to “Business Rules” finger tab.
    Step#6: Select “Entity Validators” in the list & click “+” to add a new entity level validation rule.
    Step#7: In the Pop-up, Select “Rule Type” as Unique Key
    Step#8: In the “Rule Definition” tab select the key “Unique_Manager_X_Location”created.
    Step#9: Now go to “Failure Handling” tab, and click the Magnifier Icon .
    Step#10: If the key is not already created then in the “Select Text Resource” Popup, Using the functional design document, Enter display value, Key and Description. And click “Save & Select” Button.
    Step#11: Now Click “OK”.

  • How to Create a Restricted Key Figure in BO Webi Report

    Hi Experts,
    Please tell me How to Create a Restricted Key Figure in BO Webi Report.
    Thanks in Advance.
    Regards,
    Rafi

    Hi,
    1. Define a new measure in the designer.
    2. In the select clause give the reference to the key figure on which restriction to be applied.
    For example
    @Select(Key Figures\Number of Records)
    3. In the where clause, give the MDX expression for the filter to be applied.
    For example
    <FILTER KEY="[0PURCH_ORG].[LEVEL01]">
    <CONDITION OPERATORCONDITION="InList">
    <CONSTANT CAPTION="HAS"/>
    </CONDITION>
    </FILTER>
    Regards

  • How to get the Primary key from  Synonym

    Hi ,
    I want to get the Primary Keys for my tables . I used
    java.sql.DatabaseMetaData databasemetadata = connection.getMetaData();
        ResultSet rs = databasemetadata.getTables(null, null, "%", null);
    rs.next();
        System.out.println(" TABLE_CAT "+ rs.getString(1));
        System.out.println(" TABLE_SCHEM  "+rs.getString(2));
        System.out.println(" TABLE_NAME "+rs.getString(3));
        System.out.println(" TABLE_TYPE  "+rs.getString(4));
        System.out.println(" REMARKS "+rs.getString(5)); gives :
    TABLE_CAT null
    TABLE_SCHEM PROGRESS
    TABLE_NAME ApplicConv
    TABLE_TYPE SYNONYM
    REMARKS null
    Now if I use :
      rs = databasemetadata.getPrimaryKeys(null,"PROGRESS","Applicconv");
      System.out.println("Is result set Non empty "+rs.next()); gives :
    Is ResultSet non empty false .
    Can you tell me why this result is empty? Is it because of my table is a Synonym?
    If it is Synonym how to get the primary key ?

    You can use DatabaseMetaData#getPrimaryKeys.

Maybe you are looking for

  • How can I automatically crop a photo based on its content (a black border)?

    I scanned hundred of negatives. The scanner produced .jpg files.  Most of the scanned images show the negatives holder to one side as a black border.  The black border is thicker or thinner depending on the photo. Please see pictures attached.  Is th

  • Music tapes

    Is there any way I can transfer music tapes and VHS tapes to my computer. I have got quite a few tapes thatI would like to put on CD. If so what do I need

  • Installed updates for 9.4.1...couldn't open any pdfs after that

    Yesterday I installed updates.  I tried to open several pdfs and got the message: Acrobat failed to load its core DLL.  Today I went in and removed 9.4.1 and installed the 8.something version.  I just want to let adobe know of this problem and couldn

  • Does Captivate requires Tin Can to enable tracking and viewing in iPad?

    Hi Guys, I'm using Moodle 2.6 then upload Presenter SCORMs. I need to know if Captivate SCORM supports tracking in iPad. I'm an Articulate user. Articulate requires Tin Can to enable tracking and viewing in iPad. Does Captivate requires too? We need

  • TS3694 3194 error

    We downloaded the latest IOs version on my daughters IPad and now it doesnt work because of error 3194. What is error 3194 and how do I fix her Ipad?