Linux.pl file
What is exp in plsql?

Exp was originally a command under dos or Linux command line. The rpl/sql command window is actually equivalent to the command to call oracle's sqlplus, without exp.

How to import and export Oracle data under LINUX?

Open cmd at run time.

2

Enter the command: sqlplussystem/123456 @ orcl.

Where system is the user name to log in to the database.

123456 is the password of the user name.

Orcl is the database instance name.

three

If the prompt command is invalid, it is that you have not configured oracle environment variables (I was also troubled by this problem in those days). Oracle environment variables can be configured as follows:

1, right-click "My Computer"->; Select "properties"->; Select advanced->; Click "environment variable" 2, select the line "path", click "Edit", add a semicolon ":"at the end of the variable value text box of "path", and then add the directory path of the sqlplus file after the semicolon, such as "c: programfilesoraceproduct10.2.0db _ 65438+. 3. If the variables "oracle_home" and "oracle_sid" cannot be found in the variable column under the system variable list box, you need to perform the following operations, otherwise you don't need to perform these operations. 4. Click "New" in the system variable, enter "oracle_home" in the variable name, and enter the installation directory path of oracle in the variable value, such as "C: ProgramFilesoracleproduct10.2.0db _1",and then click "OK". 5. Click "New" in the system variable, enter "oracle_sid" in the variable name, enter the instance name of the database in the variable value, and then click "OK".

Oracle _ home:Oracle installation directory of Oracle database software Oracle _ SID:Oracle instance name of Oracle database: the logo used to contact the operating system, that is, the exchange between the database and the operating system is represented by the database instance name.

end

Step 2, expdp backup command

1

Create a backup directory for oracle:

sql & gtcreatedirectorydpdata 1 as ' d:tempdmp ';

This is just a directory set in oracle, not really created.

2

You can view this directory through this command.

sql & gtselect * fromdba _ directories

three

Grant users the right to export data tables.

sql & gtgrantread,writeondirectorydpdata 1 tosshe;

four

Well, the key step is that I took a lot of detours before, and the rest were minor problems. I searched a lot of information on the internet in bits and pieces, and finally found the reason.

Switch back to the command window first, not in SQL >; Run under and enter the command:

expdpssystem/ 123456 @ orcl directory = DP data 1 dumpfile = sshe . DMP logfile = sshe . log schemas = sshe

five

Error ora-39002 is reported above: invalid operation.

The reason is that the directory d:tempdmp does not exist. Don't think that folders will be automatically generated after creating a directory, and don't think that folders will be automatically generated after executing expdp. You should manually create this directory folder yourself. Try again after creating a new folder. It really worked! Congratulations, you have successfully backed up!

six

If you want to ask, how to restore the exported dmp file. Well, to be a man in the end, in order to save you the trouble of finding another way, I will also demonstrate here (generally, the backed-up data is only used when there is a problem with the database).

First, log in to the database sqlplussystem/123456 @ orcl again.

Then, delete the target database user dropusersshecascade.

seven

Now, let's create a user again, either by command or in plsql, here in plsql.

Log in to the database with system, and then right-click users-New.

Then fill in your own account name, which must be consistent with the user at the time of backup, and give corresponding permissions.

Finally, click Apply to complete the user creation.

eight

Return to the dos command window, which is no longer sql>.

Enter the import command: impdpsystem/123456 @ orcl directory = dpdata1dumpfile = sshe.dmplogfile = sshe.logschemes = sshe.

Import succeeded!

end

Perform backup tasks regularly.

Make a batch of names by year, month and day. Create a new file in the d:temp directory and name it. Just bat, and mine is sshe.bat, and edit it into the following code.

-

@ echooffremsetbackupfile = f _ database _ % date:~ 0,4%-%date:~5,2%-%date:~8,2%。 dmpremsetlog file = f _ database _ % date:~ 0.4%-% date:~ 5.2%-% date:~ 8.2% . logremdelete 30 daysfilesforfiles/p " d:tempdmp "/d-30/c " cmd/cechodeleting @ file...del/f@path"cdd:tempdmp

Rembackupschemassetbackupfile = sshe _% Date: ~ 0.4%-% Date: ~ 5.2%-% Date: ~ 8.2%. Dmpsetlogfile = sshe _% Date: 0,4%-%Date: 5,2%-%Date: 8,2%. logexpdpsshe/sshe directory = dir _ DP dump file = % backup file % log file = % log file % schemas = sshe parallel = 4

-

You can try it. It will automatically generate a backup file named after the year, month and day.

For files/p "d: tempdmp"/d-30/c "cmd/cechodeleting @ file ... del/f @ path" is very useful for deleting the backup files in this directory after 30 days.

Do a bat in which windows automatically runs database backup every night. My name is auto.bat, and I edit the following.

-

@ echooffschtasks/create/tnssshe database is backed up regularly/tr "d: tempshe _ bak.bat"/scdaily/st00: 00: 00/ru "system" to stop exiting.

-

Double-click auto.bat, a scheduling task will be added in windows, and sshe.bat will be automatically executed at 0: 00 every night, thus completing the purpose of automatic backup.

Right-click my computer: Management-Task Scheduler-Task Scheduler Library, and you can see the newly added scheduling task.

five

You can set the computer clock to 23: 59: 50 and wait 10 seconds to see if the automatic backup can succeed. If it succeeds, it's done! !