Well, explaining it all would be too much, but the real short version s that my script wouldn't do any inserting or have access to SQL or anything, but would send information from a web script (including this unique Id) to an(other) programmer and Im required to send a proper Id so he can insert with it. Sounds silly to me, but thats what Im asked to do, so... | [reply] |
<opinion>
why doesn't your DBA or whoever is in charge of the DB and tables.. just set up an identity column. that way, each time a record gets inserted - it will have a unique ID.
</opinion>
it just may be a bit easier for you and them.
| [reply] |
Well, that's a good suggestion, but The Voice Of Reason is not resposible for much, if any, of what gets done here. The problem is that I have to send one and I need to know if this will do with no problems/errors. Thanks though.
| [reply] |
Sometimes, IDENTITY columns are a Bad Thing for uniqueness (AKA, why I like uuid instead). Why? Well, three reasons IMHO.
- They're finite. Let's take a shopping cart as a simple example. If I have an IDENTIY/AUTOINC column for each item added, that adds up over time. Will I max out that BIGINT field? Eventually. Granted it may be a loooong time down the road, but why build in that limitation to begin with?
-
Uniqueness. :-) What's the difference between row 243 in one table and row 243 in another table? Sometimes, nothing except their uuid. For example: db data change logs in an app. If each row has a unique id, then I can use it as a foreign key in the log data table. Sure I could use numbers, but uuids provide a little more assurence that the foreign key IS correct, instead of coincidentally matching by number.
-
Sometimes, IDENTITY/AUTOINC columns are pure evil. I've seen on more than one occasion that the ident/autoinc seed for a table gets reset, after which time the next IDENTITY number may actually be from a record that was previously deleted. Next thing you know a join is fubar just because a new entry aquired an old identity seed. It shouldn't happen, but it does sometimes.
My point? Good question. :-P
| [reply] |