当前位置:网站首页>Oracle database import data steps

Oracle database import data steps

2022-06-11 12:27:00 Three years old, funny

When we import data into the database , The routine steps are as follows :
The logged in user system Administrators

–【 Steps must be taken : Create tablespace 】

create tablespace test datafile 'G:\app\zky\oradata\hsp\test01.DBF' size 1024M autoextend on;
create tablespace ESB datafile 'G:\app\zky\oradata\hsp\ESB.DBF' size 1024M autoextend on;
create tablespace LIS datafile 'G:\app\zky\oradata\hsp\LIS.DBF' size 1024M autoextend on;
create tablespace EMR datafile 'G:\app\zky\oradata\hsp\EMR.DBF' size 1024M autoextend on;

notes :G:\app\zky\oradata\hsp\ESB.DBF Path the path to store the table space for your database , The above is the personal path ,autoextend on Increase the size of the table space .

–【 It's not necessary : Create user 】
create user ESB_USER identified by ESB_USER default tablespace test;
–【 It's not necessary : Create the role 】
create role ESB_ROLE;
–【 It's not necessary : Authorize roles 】
grant ESB_ROLE to ESB_USER;

–【 Steps must be taken : Create Import Directory , After creation, you need to put DMP Put the backup files of into this directory 】

create directory dump_file_dir as 'd:\expdp1';

–【 Steps must be taken :cmd function 】
–impdp user name / password @ database schemas= To import a, Users to import b, Users to import c directory=dump_file_dir dumpfile= Backup file .DMP logfile= Import log _in.log;

impdp system/[email protected] schemas=hsp,lis,esb_user   directory=dump_file_dir dumpfile=2020031901.DMP logfile=2020031901_in.log;

— Grant the user name dba Authority
–grant connect,resource,dba to user name ;

grant connect,resource,dba to hsp_cp;

— to grant authorization ( Sign in sys User authorization )

grant select on sys.v_$session to hsp_cp;

Methods described
grant SELECT ANY DICTIONARY jurisdiction ( For all dictionary tables and views );
Grant this user select on sys.v_ s e s s i o n power limit , and send use Yes power limit use Household Yes v session jurisdiction , And use authorized users to v session power limit , and send use Yes power limit use Household Yes vsession Create common synonyms ( If granted public select on sys.v_KaTeX parse error: Expected group after '_' at position 38: …select on sys.v_̲session jurisdiction , And create a pair under this user sys.v_ s e s s i o n Of private Yes Same as The righteous word ( Yes The use Household , also Yes The Depending on the chart ) . v session Private synonym for ( For this user , Also for this view ).v session Of private Yes Same as The righteous word Yes The use Household , also Yes The Depending on the chart .vsession yes v_$session Another name for

–【 Steps must be taken 】
– After importing the database, you need to PL/SQL Compiling invalid objects in

impdp hsp/test directory=lis_file_dir dumpfile=LIS20200526.dmp logfile=LIS20200526.DMP_in.log full=y table_exists_action=replace

All right. , What is mentioned above is the operation of conventional data , Generally no problem , Let's talk about special circumstances !
1, When we don't need all the data of a library , When only the data of a certain module is required , We need to import this into our local database . There is a little pit !
2, First install the general operation , Create tablespace , user , And then execute imp command .

impdp system/[email protected] schemas=hsp directory = dump_file_dir dumpfile =TEST.DMP logfile=export.log 

cmd Window error :SYS_IMPORT_FULL_01 Invalid operation scheme , Invalid object table .
reason : Maybe it's a user conflict or permission problem , The scene is not easy to restore , The statement... Is used

impdp system/[email protected] directory=DUMP_DIR dumpfile=TEST.DMP logfile=export.log remap_schema=hsp:HSP  table_exists_action=replace transform=segment_attributes:n

An error is as follows :
 Insert picture description here
The reason is that the user is not given tablespace permissions and dba jurisdiction
— Grant the user name dba Authority

--grant connect,resource,dba to   user name ;

Finally, optimize imp command :

impdp HSP/[email protected] directory=DUMP_DIR dumpfile=TEST.DMP logfile=export.log remap_schema=hsp:HSP

Success is like this :
 Insert picture description here
At last, I put up some common sentences :
– With system The user login , Find the user to delete :

– Find user

select  * from dba_users;           

– Find the path to the workspace

select * from dba_data_files; 

– Delete user

drop user hsp cascade;

– Delete tablespace

drop tablespace HSP_BLOB including contents and datafiles cascade constraint;

– Change user password

alter user HSP identified  by HSP;

– Query directory location

SELECT * FROM dba_data_files ;

– Inquire about dba Catalog

select * from dba_directories;

– Delete directory

DROP DIRECTORY  Directory name ;

for example : Delete the user name as LYK, The tablespace name is LYK

– Delete user , And cascading relationships are also deleted

drop user LYK cascade;

– Delete tablespace , And the corresponding tablespace files are also deleted

drop tablespace HSP_CLS including contents and datafiles cascade constraint;

– Query tablespace

SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size 
FROM dba_tablespaces t, dba_data_files d 
WHERE t.tablespace_name = d.tablespace_name 
GROUP BY t.tablespace_name; 
原网站

版权声明
本文为[Three years old, funny]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111209201281.html