I'm using MySQL 5.0 and I would like to know if there's a way to disable deletes on a table. As in, not make it possible for ANY user to delete anything from the tablets, only update and insert.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You can use
grant
as proposed by others. Or you can createBEFORE DELETE
trigger that raises an error, so nobody can issuedelete
against your table (keep in mind, it is still possible toTRUNCATE TABLE
)Setting permissions on your table would let you disable the delete operations. You set permissions with
GRANT
.Yes, see the MySQL manual for the GRANT syntax
Here is an example of what you want:
GRANT SELECT, INSERT ON mydb.mytbl TO 'someuser'@'somehost';
Which gives only
SELECT
andINSERT
privilages to a specific user/host on a specified table.Here's an example of a trigger: