What are the best practices for using a GUID as a primary key, specifically regarding performance? [closed]

GUIDs may seem to be a natural choice for your primary key – and if you really must, you could probably argue to use it for the PRIMARY KEY of the table. What I’d strongly recommend not to do is use the GUID column as the clustering key, which SQL Server does by default, unless … Read more

Unable to update the EntitySet – because it has a DefiningQuery and no element exist

It usually happens because one of the following reasons: Entity Set is mapped from Database view A custom Database query Database table doesn’t have a primary key After doing so, you may still need to update in the Entity Framework designer (or alternatively delete the entity and then add it) before you stop getting the … Read more

How to reset Postgres’ primary key sequence when it falls out of sync?

— Login to psql and run the following — What is the result? SELECT MAX(id) FROM your_table; — Then run… — This should be higher than the last result. SELECT nextval(‘your_table_id_seq’); — If it’s not higher… run this set the sequence last to your highest id. — (wise to run a quick pg_dump first…) BEGIN; … Read more

How can I do ‘insert if not exists’ in MySQL?

Use INSERT IGNORE INTO table. There’s also INSERT … ON DUPLICATE KEY UPDATE syntax, and you can find explanations in 13.2.6.2 INSERT … ON DUPLICATE KEY UPDATE Statement. Post from bogdan.org.ua according to Google’s webcache: 18th October 2007 To start: as of the latest MySQL, syntax presented in the title is not possible. But there … Read more

tech