SQL: delete all the data from all available tables

前端 未结 9 1180
小蘑菇
小蘑菇 2020-12-09 08:43

I am using oracle DB to maintain more than 30 tables, how can I delete all the data from all the tables? I only want to delete the data but not drop the tables.

9条回答
  •  孤街浪徒
    2020-12-09 09:12

    A slight variation on Andomar's answer to truncate all tables for a specific user instead of only those of the current user:

    SELECT 'TRUNCATE TABLE ' || owner || '.' || table_name || ';' FROM all_tables WHERE owner = 'user/schema'
    

    Replace the user/schema bit above with the name of the user/schema (between the quotes) you are interested in.

提交回复
热议问题