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

  • SEARCH
  • Home
  • 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 6836069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:18:38+00:00 2026-05-26T23:18:38+00:00

when using compound pk, can insertion of values be the same ? I illustrate

  • 0

when using compound pk, can insertion of values be the same ? I illustrate an example to you guys:

Creation of table:

Create table test
(
testno number(5) not null,
testpaper varchar(2) not null,
time date
CONSTRAINT Pa_Pks PRIMARY KEY (testno, testpaper) 
)

Then this is the values that i would like insert:

Testno          Testpaper         Time
12345           22                14-JUL-2011
12345           23                15-JUL-2011
12345           22                16-JUL-2011

As you can see that my primary keys have the same values during insertion. The reason of why i would like to do that is the same testno and testpaper can happen on different dates.

How can i do that if i would like to add in same values but label it as primary key?

This should be the standard and correct way to do it:

Create table TEST
(
 Testid number(1) not null,
 testno number(5) not null,
 testpaper varchar(2) not null,
 time date
 CONSTRAINT Pa_Pks PRIMARY KEY (Testid) 
)

Thanks for any clarification.

  • 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-26T23:18:39+00:00Added an answer on May 26, 2026 at 11:18 pm

    No you cant do that, Primary Key has to be Unique. However what you can do is that you can add Test Time as part of the Key. Or you can have another column name as Id, this will be an Auto Increment Key. So your Primary Key will be ID (Auto Increment).

    In oracle if you want to have an AutoIncrement Key, then you will have to write sequence and trigger also. A sequence is simply a series of number. The purpose of trigger will be to increment the number whenever new row is inserted, and store it in the column id. , And you may also wanna increase the size of Number. Number(1) might not be good enough size for primary key.(If you want Oracle to have an auto increment Id) OR Simple you can add Time to your primary Key.

    The standard depends on your requirement. Both approaches are followed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can you create models (and thus tables) with a compound (composite) primary/unique key
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
This tag and its children can be replaced by one and a compound drawable
I would like to create a compound component that consists of a TextView (integer
how would you parse a Microsoft OLE compound document using Python? Edit: Sorry, I
Hi guys I am migrating an application using hibernate from xml to JPA annotations.
Using this statement: select * from qvalues where rowid ,name,compound in ( select rowid,name,compound
How can I use an alias across different select statements or across a compound
I am trying to run an awk script using python, so I can process

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.