当前位置:网站首页>Record the problems encountered in importing the DMP file into Oracle database (on the local wire) and the solutions

Record the problems encountered in importing the DMP file into Oracle database (on the local wire) and the solutions

2022-06-09 04:33:00 If time comes again

install oracle Environmental Science (instantclient)

Because... Has been installed on the line oracle Complete version database , Then you only need to install instantclient You can import data
Please refer to :https://blog.csdn.net/admin_web/article/details/125103786

Use navicat Tool View oracle data

open navicat After the tool, select... In the menu bar file -> make new connection ->oracle, Enter the address of the connection 、 port 、 service name 、 User name, password .
Service name is installation oracle It's set at , The default is ORCL
 Insert picture description here
If you want to use sysdba After selecting advanced, the user selects the role as sysdba
 Insert picture description here

Ready to start importing

1. Log in to the online server oracle database , Use sqlplus / as sysdba Create a new tablespace after the superrule role enters 、 Users and assigning permissions to users
Create tablespace

( Every self increment of table space 200m)

create tablespace MY_TAB datafile 'D:\oracle\oradata\DANTE_TEMP.DBF' size 4096M AUTOEXTEND ON NEXT 200M

Configure multiple storage files for the same tablespace

--  Add a certain number of data files as needed 
alter tablespace MY_TAB add datafile 'D:\oracle\oradata\DANTE_TEMP2.dbf' size 320m autoextend ON next 100 m maxsize unlimited;
alter tablespace MY_TAB add datafile 'D:\oracle\oradata\DANTE_TEMP3.dbf' size 300m autoextend ON next 100 m maxsize unlimited;
alter tablespace MY_TAB add datafile 'D:\oracle\oradata\DANTE_TEMP4.dbf' size 300m autoextend ON next 100 m maxsize unlimited;

Create users and allocate tablespaces to them

create user mytest( user name ) identified by 123456( password ) default tablespace MY_TAB( Table space name );

Assign permissions to users

GRANT CONNECT,RESOURCE,DBA TO c##mytest;

Connect role
Is a typical right granted to end users , The most basic rights , Be able to connect to Oracle In the database , And when you have access to other users' tables , do SELECT、UPDATE、INSERTT Wait for the operation .

Alter session– Modify session ;

Create cluster– Build clusters ;

Create database link– Establish a database connection ;

Create sequence– Set up a sequence ;

Create session– Establish a conversation ;

Create synonym– Build synonyms ;

Create view– Create view .

Resoure role
It's for developers , Be able to create tables in your own solution 、 Sequence 、 View etc. .

Create cluster– Build clusters ;

Create procedure– Establishment process ;

Create sequence— Set up a sequence ;

Create table– Build table ;

Create trigger– Set up the promoter ;

Create type– Build type .

DBA role
It's for the system administrator , Users with this role can become system administrators , It has all the system permissions .

2. Use imp The order will be local dmp File import to online oracle in
Use imp -help Command to view all parameters
imp user name / password @ip Address : Port number / service name file= To import dmp file full=y indexes=N log= journal statistics=none

full=y : Import all data of the file ,
indexes=N : Whether to import table index N no Y yes , Default Y
rows=N : Import data lines (Y) ,N Only import table structures
statistics=none : Do not import or re count database statistics
DATA_ONLY=Y : Just import data

imp mytest/[email protected]:1521/ORCL file=D:\upload_file\orcl1.dmp full=y indexes=N log=D:\upload_file\orcl.log statistics=none

Export table mechanism only

exp mytest/[email protected]/orcl file=D:\tablejg.sql rows=n  // Derived table structure 

Use bat The batch will dmp File import to server
Pictured : To import dmp Files are placed in the same directory
 Insert picture description here
a.bat

@echo off

setlocal EnableDelayedExpansion
set localPath=./
set host=xx.x.xx.xxx
set user=mytest
set pwd=123456
set num=0

for /r %localPath% %%i in (*.dmp) do (
    set /a num+=1
    imp %user%/%pwd%@%host%/ORCL file=%%i full=y statistics=none indexes=N DATA_ONLY=Y log=%localPath%\!num!_s2.log
)


pause

Problems encountered during import

problem ------------

 Insert picture description here
Cause analysis : After inquiry , It is found that the cause of this error is the database statistics . But the deeper reason , It's not clear . For the time being, I understand that , Because the default import policy is statistics=always, This strategy requires that the original database statistics must be imported , This strategy , I still think there is something wrong , Database statistics , Because the new database version is used , Original statistics , Basically 80% The left and right statistics should be incorrect , So why should the import policy default to statistics=always Well . therefore , My decision is not to import or recalculate database statistics .
Reference resources :https://blog.csdn.net/weixin_35986494/article/details/116441481
resolvent : Add... To the import statistics=none

problem ------------
 Insert picture description here
Cause analysis : It may be due to permissions or imported dmp The table fields in the file are inconsistent with those on the server ( What I met was the latter )
resolvent :
1. Re export after unifying the required table fields
2. Append the missing fields to the imported data table , Pictured above : take "DATASRC" Fields are appended to the imported table

原网站

版权声明
本文为[If time comes again]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090431094572.html