Skip to Content
author's profile photo Former Member
Former Member

Diff primary key and secondary key

Hi Gurus,

in table's there is key like primary and secondry?. what is the difference between primary key and secondary key.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 19, 2009 at 02:21 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 19, 2009 at 02:37 AM

    Hi nareshkumar,

    Primary key

    If no WITH key declaration is made, a table type is generic with respect to the primary key.

    If a declaration about the uniqueness of the key is not made in key, a table type is partially generic with respect to the key.

    If a key declaration with a uniqueness declaration is made in key, a table type is not generic with respect to the primary key.

    The non-generic table categories can be split up as follows:

    If no primary key is declared for standard tables, this primary key is generic with respect to the key fields and defined implicitly as non-unique.

    If no primary key is declared for sorted tables, this primary key is generic with respect to the key fields and uniqueness.

    If no primary key is declared for hashed tables, this primary key is generic with respect to the key fields and uniqueness; note, however, that fixed hash tables can have only one unique key.

    Secondary key

    The genericness of a table type with respect to the secondary key depends (by default) on the genericness of the primary key; you can override it with the WITH|WITHOUT FURTHER SECONDARY KEYS additions.

    If the primary key is completely or partially generic, then the table type is by default generic with respect to the secondary key. The standard response can be expressed using the WITH FURTHER SECONDARY KEYS addition. However, if the WITHOUT FURTHER SECONDARY KEYS addition is declared, the table type is generic with respect to the primary key but not with respect to the secondary key.

    If the primary key is not generic, then the table type is not generic with respect to the secondary key either (by default). The standard response can be expressed using the WITHOUT FURTHER SECONDARY KEYS addition. If, however, the WITH FURTHER SECONDARY KEYS is declared, the table type is generic with respect to the secondary key but not with respect to the primary key.

    Thanks,

    Swamy H P

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 19, 2009 at 03:24 AM

    Primary key

    The field which is Unique and not null is called the Primary Key field

    Foreign Key

    To establish the relations between 2 tables the same key field in another table is the Foreign key. Foreign key may or may not be Unique and not-null.

    thanks

    G. Lakshmipathi

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.