Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. alter table

alter table

Scheduled Pinned Locked Moved Database
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FEMDEV
    wrote on last edited by
    #1

    Hi, Will adding a foreign key column to an existing table with data, by using alter table command affect the existing data in the table?

    B 1 Reply Last reply
    0
    • F FEMDEV

      Hi, Will adding a foreign key column to an existing table with data, by using alter table command affect the existing data in the table?

      B Offline
      B Offline
      Bassam Saoud
      wrote on last edited by
      #2

      you wont be able to create the key if any record violate that foriegn key constraint. you would probably have to clean the data [ if any violates] before being able to create the constraint

      F 1 Reply Last reply
      0
      • B Bassam Saoud

        you wont be able to create the key if any record violate that foriegn key constraint. you would probably have to clean the data [ if any violates] before being able to create the constraint

        F Offline
        F Offline
        FEMDEV
        wrote on last edited by
        #3

        adding a foreign key will not conflict with existing data but it would help in data integrity. am only concerned if it will result in any loss of data already existing. I know that it should not but since i've never done this before on a table in production environment with data just needed to be doubly sure that it results in no data loss.

        L 1 Reply Last reply
        0
        • F FEMDEV

          adding a foreign key will not conflict with existing data but it would help in data integrity. am only concerned if it will result in any loss of data already existing. I know that it should not but since i've never done this before on a table in production environment with data just needed to be doubly sure that it results in no data loss.

          L Offline
          L Offline
          loyal ginger
          wrote on last edited by
          #4

          You may not want to do this in production environment. Try to duplicate the data in development environment and test it before doing it in a live production environment. I want to say it will not cause data loss, but I still suggest you to do it in development environment. We had mishaps on production environment before, even though we believed everything should be okay. When that happens, it may keep you in your office for a few days without any sleep.

          F 1 Reply Last reply
          0
          • L loyal ginger

            You may not want to do this in production environment. Try to duplicate the data in development environment and test it before doing it in a live production environment. I want to say it will not cause data loss, but I still suggest you to do it in development environment. We had mishaps on production environment before, even though we believed everything should be okay. When that happens, it may keep you in your office for a few days without any sleep.

            F Offline
            F Offline
            FEMDEV
            wrote on last edited by
            #5

            :) Many Thanks all. Done successfully

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups