0

How to backup of all Table data from sql developer as scripts,

I am going to truncate all the table to clean up the datas before to that i want to backup all the datas as scripts in my local folder.

Need to know: -> How to backup of all Table data from sql developer as scripts, -> How to truncate of all Table data at one shot

Thanks Abinnaya

6
  • Tools - Database Export - Save As Separate Files. Check enable 'export data'. Commented Jun 7, 2023 at 14:52
  • Writing code that automates table truncation is generally a bad idea. Commented Jun 7, 2023 at 14:53
  • Writing code that automates table truncation is generally a bad idea. – its just test database need to clean up the records to update live datas
    – Abinnaya
    Commented Jun 7, 2023 at 14:54
  • then just drop the schema and recreate it Commented Jun 7, 2023 at 15:11
  • that not a good idea, thanks let me google it
    – Abinnaya
    Commented Jun 7, 2023 at 15:12

1 Answer 1

0

DUMP ALL TABLES OF A SCHEMA

You can use expdp util given by Oracle. All you have to do is open a command prompt and navigate to the SQLDeveloper installation directory and run the following command.

expdp username/password@database SCHEMAS=schema_name DIRECTORY=directory_name DUMPFILE=backup_file_name.dmp

This will dump all your table along with data in one go.

Please change the values of username, password, database, schema_name etc. accordingly.

TRUNCATE ALL TABLES IN ONE SHOT

Use the following anonymous block

BEGIN
  FOR tbl IN (SELECT table_name FROM user_tables) LOOP
    EXECUTE IMMEDIATE 'TRUNCATE TABLE ' || tbl.table_name;
  END LOOP;
END;

Please change the query accordingly and add WHERE if required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.