sql >> データベース >  >> RDS >> Mysql

MySQL:テーブルの切り捨てとテーブルからの削除

    テーブルから削除

    1. DELETE is a DML Command.
    2. DELETE statement is executed using a row lock, each row in the table is locked for deletion.
    3. We can specify filters in where clause
    4. It deletes specified data if where condition exists.
    5. Delete activates a trigger because the operation are logged individually.
    6. Slower than truncate because, it keeps logs.
    7. Rollback is possible.
    8. LIMIT clause can also be used to set a limit on the number of rows to be deleted.
    9. ORDER BY clause can be used in DELETE statement. In this case, the rows are deleted in the specified order.
    

    テーブルの切り捨て

    1. TRUNCATE is a DDL command.
    2. TRUNCATE TABLE always locks the table and page but not each row.
    3. Cannot use Where Condition.
    4. It Removes all the data reset the auto increment number.
    5. TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.
    6. Faster in performance wise, because it doesn't keep any logs.
    7. Rollback is possible.
    8. Cannot use LIMIT and ORDER BY.
    

    削除 および切り捨て TRANSACTIONで使用すると、両方をロールバックできます。自動インクリメントの主キーがある場合、切り捨てるとカウンターがリセットされます。




    1. SQLServerデータベースで一意の制約を持つ列のリストを取得する方法-SQLServer/TSQLチュートリアルパート98

    2. MySQLでの日付の解析

    3. phpMyAdminでデータベースを管理する方法

    4. MySQLdb Pythonは%dと%sを挿入します