


You mention date is that actually a DATETIME? If there are several entries for one product+stage in 5 minutes, then please provide more details.
Mysql insert into without primary key update#
How many product-stage pairs are there? (I want to estimate how soon an `INT UNSIGNED would overflow.) Here is the query with both INSERT and UPDATE clauses (T-SQL syntax): IF condition here BEGIN UPDATE usersremark SET remark 'testing123' WHERE userid1 AND remarkuserid 3 END ELSE BEGIN INSERT INTO usersremark (userid, remarkuserid, remark) VALUES (1, 3, 'testing123) END. Its true, without a primary key (or some unique key), you dont have an insertion anomaly if you go to insert the same data multiple times. It makes it much easier to maintain the data. The update would change the value and the datetime. Every table should have some column (or set of columns) that uniquely identifies one and only one row. If there is only one entry per (product_id, dev_stage_id) each 5 minutes, it seems like that pair could be the PK, and a simple UPDATE would be better than a delete+insert. It’s also a common operation performed by developers, DBAs, and data analysts when setting up or updating databases. This process is essential for data migration, backups, and integrating MySQL with other systems. Without an explicit PK, a hidden 6-byte number will be provided. Data import in MySQL involves transferring data from external files or databases into a MySQL database. But, a PK is important, even if it is a mostly-useless id.

This allows the old data to survive until the new data is in place.Īlso, the term "log" usually implies data that is kept "forever" (or at least a lot longer than 5 minutes). For one thing, if all the data is being tossed, then TRUNCATE may be a better approach. The Question is vague on how many rows are deleted every 5 minutes, so my answer is a bit vague. I'm trying to use an INSERT INTO statement without having to entering the primary key - apparently I shouldn't need to, it should update itself. The StudentID field is set as a Primary Key and Not Null and AutoIncrement. Short answer: Yes, you can simply and safely remove id and the PK. I have five fields, StudentForename, StudentSurname, StudentAge, StudentHouse and StudentID for the Primary Key.
