Reputation: 887
I have a table that was doing fine with no unique keys so far. This table is working fine but the code of inserting/updating/deleting procedures is getting a bit unreadable since conditions to recognize a correct entry in table are getting longer and longer, so I started to consider adding a new column with an unique ID to it.
There are already answered questions about adding a unique identity to table on SO, but I was wondering if it can have any negative impact on currectly existing records. The table itself isn't big, it never has more than a few thousands of entries, but it's used and updated often and it wouldn't be easy to stop using it for more than a moment. So is there anything I should be aware of that could mess up the data or can I just happily add a column with unique identity and everything will work just fine? Can there be any problems with currently existing stored procedures, especially the ones altering the records? To be honest I can't think of anything but I'd rather be sure since I'm far from being experienced in SQL and databases.
Same for adding indexes to an already existing table - I imagine there would be some shifting around involved, so is there any negative impact on the records?
If you need examples of the procedures I mentioned, just think of simple insert/delete/update statements with needlessly long where clauses. No joins with other tables, no multiple transactions within a single procedure.
Upvotes: 1
Views: 174
Reputation: 171178
The current data will not be affected by adding columns or changing indexes.
But code might be affected.
SELECT *
will now return more columns.INSERT
without a column list. That will now fail.I'm sure there are others but these are the ones that I can think of right now.
Upvotes: 1