Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7173917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:55:29+00:00 2026-05-28T15:55:29+00:00

Reference:Oracle documentation Oracle Database enforces all PRIMARY KEY constraints using indexes Q’s 1> I

  • 0

Reference:Oracle documentation “Oracle Database enforces all PRIMARY KEY constraints using indexes”

Q’s

1> I did not understand the reason behind having a constraint and a key(that would also implement the constraint i.e. in this case PRIMARY KEY constraint and PRIMARY KEY index)?

2> Should I implement a key or a constraint when building database tables?

3> Are there any scenarios where using one over the other would be a +ve/-ve factor?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:55:30+00:00Added an answer on May 28, 2026 at 3:55 pm

    I’m not sure that I understand the question.

    In Oracle, when you declare a primary key constraint, Oracle will implicitly create an index to enforce that constraint if no suitable index already exists to enforce the constraint. It is not an “either/or” situation where you create one or the other– you’re always going to have both a primary key constraint and an index to enforce that constraint.

    You do have a choice about whether to create the index separately prior to creating the constraint and telling Oracle to use the index to enforce the constraint or whether to allow Oracle to implicitly create the index. It generally doesn’t matter which approach you choose but there are things to be aware of.

    1. If you create the index first, you have the ability to do things like specify the tablespace that the index will reside in. This won’t have a performance benefit but some DBAs prefer to organize tablespaces to separate tables and indexes.
    2. If you create the index first, dropping the constraint in the future will not drop the index. That may be good or bad, it depends what the person that drops the constraint expects. It is useful, however, to be consistent so that if someone needs to drop constraints in the future that all constraints behave similarly.
    3. If you create the index first, it is possible to use indexes that involve other columns to enforce the primary key. If you know, for example, that you want to have a composite index on your primary key and some other column, you can use that index to enforce the primary key rather than having potentially redundant indexes created, i.e.
    4. If Oracle implicitly creates the index, the index name will match the constraint name. If you create the index first manually, the names may differ. It doesn’t technically matter whether the names match but you may have scripts that rely on a name match to link constraints to indexes.

    An example that creates a non-unique composite index with a different name than the primary key constraint that is then used to enforce the primary key constraint.

    SQL> create table foo( col1 number, col2 number );
    
    Table created.
    
    Elapsed: 00:00:00.01
    SQL> create index idx_foo on foo( col1, col2 );
    
    Index created.
    
    Elapsed: 00:00:00.00
    SQL> alter table foo
      2    add constraint pk_foo
      3        primary key( col1 )
      4        using index idx_foo;
    
    Table altered.
    
    Elapsed: 00:00:00.13
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the following text is an excerpt of oracle documentation Oracle® Database PL/SQL Language Reference
Object reference not set to an instance of an object. using System; using System.Collections.Generic;
On a oracle database I have a foreign key, without knowing its name, just
Unable to create table as oracle shows ' no matching unique or primary key
I was reading Oracle Database 11g The Complete Reference and came across the following
I am trying to insert values into Oracle 10g database using the code below
In Oracle I can declare a reference cursor... TYPE t_spool IS REF CURSOR RETURN
For reference, I'm using Visual Studio 2010. I have a custom build step defined
Possible Duplicate: A good reference for Oracle PL/SQL I need make a procedure to
I am using weblogic JDBC datasource and my DB is Oracle 10g, below is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.