Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • To Create and Drop Primary and Foreign Key Constraint in SQL

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 191
    Comment on it

    In SQL we can create the primary key


    Ex: create table student 
    (
    stid int primary key identity(1,1),
    stname varchar(50)
    )
    


    In SQL we can also create the foreign key using SQL query


    Ex: create table account
          (
       staccid int primary key identity(1,1),
       stid int references student(stid) 
           )
    


    In SQL we can delete the primary key constraint using the alter command


      Ex:   ALTER TABLE Persons
            DROP CONSTRAINT pkPersonID
    


    Same has been done to remove the foreign key reference


      Ex:    ALTER TABLE Orders
               DROP CONSTRAINT fkPerOrders
    
    SQL

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: