时间:2021-07-01 10:21:17 帮助过:8人阅读
Docker 环境部署的oracle
#查询oracle 实例
docker ps -a
#进入实例
docker exec -it 58aca4848691 /bin/bash
#切换oracle用户
su - oracle
#设置oracle 环境变量
export ORACLE_HOME=/u01/app/oracle-product/12.1.0/xe
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=xe
打开sqlplus:
sqlplus / as sysdba
select * from dba_directories;
create directory dump_dir as ‘/home/oracle/tmp‘;
grant read,write on directory my_dir to scott
create user fms identified by fms;
alter user fms identified by fms;
select username,default_tablespace from dba_users;
create tablespace fms_cloud_ym_data datafile ‘/u01/app/oracle/oradata/xe/fms_cloud_ym_data.dbf‘ size 500M reuse autoextend on next 10M maxsize unlimited extent management local autoallocate;
create user fms_cloud_ym identified by fms_cloud_ym default tablespace fms_cloud_ym_data temporary tablespace TEMP profile DEFAULT;
##修改用户表空间
alter user fms default tablespace fms;
grant create user,drop user,alter user,create any view, select any table,delete any table, insert any table,update any table, drop any view ,exp_full_database,imp_full_database, create database link, connect,resource,create session to fms_cloud_ym;
用户权限说明
12c修改用户:
alter user fms_cloud_ym QUOTA UNLIMITED ON fms_cloud_ym;
impdp fms_cloud_ym/fms_cloud_ym@10.1.4.37:1521/xe
--导入文件所在文件夹
directory=dump_dir
--导入dmp文件名
dumpfile=20201211_fms_cloud.dmp
--从 fms_cloud用户 到 fms_cloud_ym
remap_schema=fms_cloud:fms_cloud_ym
--从表空间 fms_cloud_data 到 fms_cloud_ym_data
remap_tablespace=fms_cloud_data:fms_cloud_ym_data
--导出日志文件
ogfile=fms_cloud_ym_data.log;
参数说明:
导入模式:
导入用户(从用户scott导入到用户scott)
impdp scott/tiger@orcl directory=dump_dir dumpfile=expdp.dmp schemas=scott logfile=impdp.log;
导入表(从scott用户中把表dept和emp导入到system用户中)
impdp fms_cz_md/fms_cz_md@localhost:1521/xe dumpfile=CURVECNBD.DMP tables=fms_cloud_md.t8_bond_curvecnbd remap_schema=fms_cloud_md:fms_cz_md REMAP_TABLESPACE=fms_cloud_md:fms_cz_md logfile=imp_curvecnbd.log table_exists_action=append/replace;
导入表空间
impdp system/manager@orcl directory=dump_dir dumpfile=tablespace.dmp tablespaces=example logfile=impdp.log;
导入整个数据库
impdb system/manager@orcl directory=dump_dir dumpfile=full.dmp full=y logfile=impdp.log;
expdp fms_cloud_ym/fms_cloud_ym@10.1.4.37:1521/xe
--指定导出用户
schemas=fms_cloud_ym
--导出文件名
dumpfile=20210223_fms_cloud_ym.dmp
--导出文件夹
directory=data_pump_dir
--导出 日志
logfile=fms_cloud_ym.log;
导出模式:
导出用户及其对象
expdp scott/tiger@orcl schemas=scott dumpfile=expdp.dmp directory=dump_dir logfile=expdp.log;
导出指定表
expdp fms_cloud_md/fms_cloud_md@localhost:1521/orcl tables=fms_cloud_md.t8_bond_curvecnbd dumpfile=curvecnbd.dmp directory=dump_file logfile=exp_curvecnbd.log;
按查询条件导
expdp scott/tiger@orcl directory=dump_dir dumpfile=expdp.dmp tables=empquery=‘where deptno=20‘ logfile=expdp.log;
按表空间导
expdp system/manager@orcl directory=dump_dir dumpfile=tablespace.dmp tablespaces=temp,example logfile=expdp.log;
导整个数据库
expdp scott/123@127.0.0.1/orcl directory=dump_dir dumpfile=ly.dmp full=y logfile=expdp.log;
select object_name, machine, s.sid, s.serial#
from v$locked_object l, dba_objects o, v$session s
where l.object_id = o.object_id
and l.session_id = s.sid;
alter system kill session ‘2835, 18388‘;
drop user fms_cloud_test cascade;
drop tablespace fms_cloud_test including contents and datafiles;
select a.tablespace_name "表空间名",
total "表空间大小",
free "表空间剩余大小",
(total - free) "表空间使用大小",
total / (1024 * 1024 * 1024) "表空间大小(g)",
free / (1024 * 1024 * 1024) "表空间剩余大小(g)",
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(g)",
round((total - free) / total, 4) * 100 "使用率 %"
from (select tablespace_name, sum(bytes) free
from dba_free_space
group by tablespace_name) a,
(select tablespace_name, sum(bytes) total
from dba_data_files
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name;
select username,sid,serial#,paddr from v$session where username=‘FMS_CLOUD_TEST‘;
alter system kill session ‘4,7187‘;
alter system kill session ‘65,561‘;
alter system kill session ‘162,2999‘;
alter system kill session ‘192,2132‘;
drop database link "MarketData";
Create database link
create database link "MarketData"
connect to fms_cloud_ym_md identified by "fms_cloud_ym_md"
using ‘(DESCRIPTION =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.4.37)(PORT = 1521)))
(CONNECT_DATA =(SERVICE_NAME = xe)))‘
Oracle 常用操作
标签:bin ade ted directory 模式 kill cti example export