• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drop Primary Key Constraint

 
prathimaprasun rao
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I have a form with fields sno, sname. I added a new field 'class' which is a list box with values 1 to 10.All the information related to sno, sname and class are stored in the student table.The class field has primary key.Now i want to drop the primary key which exists on this class field. So I executed "alter table student drop primary key(class);
It displayed an error message:ORA-01735:invalid alter table option. The reason why I want to drop this primary key is because when i try to open the legacy records on this form which do not have this new field does not allow me to save this form as this field has primary key constraint. If I can drop this constarint then I can update the student table with some default value in this class field for the legacy records as this field would be null for those records.Could any one let me know how to drop the primary key ?
Thanks,
Prathima
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prathima,
You can't drop a primary key altogether. You would need to pick a different column or columns to be the primary key instead.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose you can do that. In fact, your query was wrong.

Try this,
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
You can't drop a primary key altogether. You would need to pick a different column or columns to be the primary key instead.


It is not like, we have to have a primary key in a table. I believe, you can't drop a primary key when there is a reference (foreign key) present. And in that case the complaint would be different.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic