oracle新建表空间新建用户授权,数据泵导入导出
Posted 清_澈
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle新建表空间新建用户授权,数据泵导入导出相关的知识,希望对你有一定的参考价值。
-- 新建表空间
create tablespace PLATEDATA
logging
datafile 'D:\\oracle\\oradata\\orcl\\PLATEDATA.dbf'
size 4096m
autoextend on
next 256m maxsize 20480m
extent management local;
--新建用户
create user platedata identified by platedata
default tablespace platedata
temporary tablespace temp;
--授权
grant connect,resource,dba to platedata;
grant select any table to platedata;
--用户导出(一般用这个)
exp platedata/platedata file=D:/oracle/oradata/platedata.dmp owner=platedata --只导出该用户所属内容
--用户导入(一般用这个)
imp platedata/platedata file=D:/oracle/oradata/platedata.dmp formuser=platedata touser=platedata
--数据泵(expdp/impdp), expdp和impdp只能在数据库服务端使用
-- 创建 directory ,并授权
create directory expdir as 'D:/oracle/oradata/orcl';
grant read,write on directory expdir to platedata;
impdp username/passwd directory=expdir dumpfile=data.DMP REMAP_SCHEMA=username:username
--导出一张表
expdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=expdp.log tables=tablename
--导出多张表:
expdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=expdp.log tables=tablename1,tablename2
--导出一个用户
expdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=expdp.log schemas=username
--导出用户存储过程:
expdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=expdp.log schemas=username include=procedure
--导出用户元数据(包含表定义、存储过程、函数等):
expdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=expdp.log schemas=username content=metadata_only
--导出用户函数和视图:
expdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=expdp.log schemas=scott exclude=index
--导入dmp文件中的所有数据:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log full=y
--导入一张表,例:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log tables=tablename
--导入多张表,例:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log tables=tablename1,tablename2
--导入一个用户,例:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log schemas=username
--导入多个用户,例:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log schemas=username1,username2
--并行导入:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log parallel=8
--导入元数据(包含表定义、存储过程、函数等等):
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log content=metadata_only
--导入存储过程:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log include=procedure
--导入函数和视图:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log include=function,view
--导入数据,但不包括索引:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log exclude=index
--重命名表名导入:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log remap_table=tablename1:tablename2
--重命名schema名导入:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log remap_schema=username1:username2
--重命名表空间名导入:
impdp username/passwd directory=mydata dumpfile=expdp.dmp logfile=impdp.log remap_tablespace=tablespacename1:tablespacename2
SELECT BGT_ID, DEP_BGT_ECO_CODE, FISCAL_YEAR, TP_FUNC_CODE FROM BA_BGT_INFO_V1 T WHERE T.IS_DELETED = '2' AND T.FISCAL_YEAR = '2022' AND T.TP_FUNC_CODE IS NOT NULL AND T.DEP_BGT_ECO_CODE IS NOT NULL AND
(mof_div_code like '3707%' or mof_div_code like '3703%') and ROWNUM < 6
-- 2022-10-17 淄博和潍坊 数据质量 调整sql
--表内勾稽关系 【BN-ZBXXB04】当转移支付支出功能分类科目代码不为空时,部门支出经济分类科目代码应为空。(指标信息表)
update BA_BGT_INFO_V1 t
set DEP_BGT_ECO_CODE = null,
send_date=SYSDATE-(1/(24*60*60)*(TRUNC(ROWNUM/10000)+1))
WHERE
T.IS_DELETED = '2' AND T.FISCAL_YEAR = '2022' AND T.TP_FUNC_CODE IS NOT NULL AND T.DEP_BGT_ECO_CODE IS NOT NULL AND
(mof_div_code like '3707%' or mof_div_code like '3703%')
--空值 预算信息表 -区划名称
merge into BGT_PM_ANNUAL_V1 a using (SELECT b.mof_div_code , b.mof_div_name from
LFS_MOF_DIV_V1 b where b.mof_div_code like '3707%' or b.mof_div_code like '3703%' )b on (a.mof_div_code = b.mof_div_code)
when matched then update set a.mof_div_name = b.mof_div_name
where a.IS_DELETED = '2' AND ( TRIM( a.MOF_DIV_NAME ) IS NULL OR TRIM(a.MOF_DIV_NAME ) = '-' OR TRIM(a.MOF_DIV_NAME ) = '_' OR TRIM(a.MOF_DIV_NAME ) = '*') AND a.FISCAL_YEAR = '2022' AND
(a.mof_div_code like '3707%' or a.mof_div_code like '3703%')
;
以上是关于oracle新建表空间新建用户授权,数据泵导入导出的主要内容,如果未能解决你的问题,请参考以下文章