Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to create many primary key for a table?

Former Member
0 Kudos

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.

6 REPLIES 6

eddy_declercq
Active Contributor
0 Kudos

Hi,

A table can span multiple columns if that's the idea behind your question. Check also

http://help.sap.com/saphelp_nw2004s/helpdata/en/3c/384c4005a99523e10000000a1550b0/frameset.htm

PS.

Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.

Spread the wor(l)d!

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

No, you can only define one primary key for a table. You can create multiple secondary indexes for your db table via SE11.

Regards,

Rich Heilman

arvind_aj
Associate
Associate
0 Kudos

You can create many primary keys in a table. This becomes combinational primary key. This means, the combination of all primary keys acts as primary key for that table ( combination of data in all primary key field should be unique ).

former_member192029
Active Contributor
0 Kudos

Hi Selva,

A table consist of rows & columns. So, you can define a primary key in several columns in the table.

here you go the example

CREATE TABLE hotel.person

(pno FIXED(6),

name CHAR(20),

city CHAR(20))

Add a primary key:

ALTER TABLE hotel.person ADD PRIMARY KEY (pno,name)

Cheers

Jawahar Govindaraj

PS:Reward pts

Former Member
0 Kudos

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

0 Kudos

Hi,

Pls don't forget to reward points and close the question if you find the answers useful.

Eddy

PS.

Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.

Spread the wor(l)d!