How do I back up a table in Oracle database?
To back up a table, you can use the expdp tool provided by Oracle database to export it. The specific steps are as follows:
- Login to the command line interface of the Oracle database, logging in with sysdba credentials.
- Run the following command to create a directory object for storing backup files:
- CREATE DIRECTORY backup_dir AS ‘/backup/directory/path’;
- Execute the following command to grant directory object to the user:
- Give permission for your_user to read and write in the backup_dir directory.
- Execute the following command to export table data and structure to a backup file:
- Export your_table from your_service_name using your_user credentials to backup_dir directory with the filename your_table_backup.dmp and log details saved in your_table_backup.log.
- your_user is the owner of the table to be backed up, password is the user’s password, your_service_name is the database service name, your_table is the table to be backed up, your_table_backup.dmp is the name of the backup file, and your_table_backup.log is the export log file name.
- After the execution is completed, backup files will be generated in the specified backup directory.
Note: Backup files can be used with the impdp tool for importing and restoring operations.