Results 1 to 5 of 5

Thread: deleting constraints in table

  1. #1

    deleting constraints in table

    Can u delete constraints in a table? if yes, how?
    Can u delete primary and foreign key?
    How to delet columns in a table after creating the table with some data in it?


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: deleting constraints in table

    yes u can drop constraints in a table using 'alter command'
    ALTER TABLE emp DROP CONSTRAINT pk_employee
    ALTER TABLE foreign_table DROP CONSTRAINT fk_name
    Alter table drop column columnname


  3. #3
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: deleting constraints in table

    I think what you are asking is droping not deleting. Since you want to change the structure it is called drop in technical terms not delete. Delete refers to deletion of data only not structure. Since you want to change the structure use alter command as suggested by our expert in the previous post.


  4. #4
    Contributing Member
    Join Date
    Apr 2008
    Answers
    31

    Re: deleting constraints in table

    Hi Saritha,

    You use the fallowing query to see the total information of the table. from that you can use to delete or drop the primary or forign keys.

    select * from sysobjects where type='u' and name='tablename';


  5. #5
    Expert Member
    Join Date
    Nov 2008
    Answers
    300

    Re: deleting constraints in table

    You can also delete a primary key if you dont know the name of the primary key by saying:

    Code:
    ALTER TABLE table_name DROP primary key



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact