--创建用户
create user NF_NFZC identified by NF_NFZC;
--修改口令
alter user NF_NFZC identified by 123456;
--删除用户
drop user NF_NFZC;
--用户授权
grant connect, resource to 用户名;
grant connect, resource to NF_NFZC;
--撤销权限
语法: revoke connect, resource from 用户名;
列子: revoke connect, resource from NF_NFZC;
--创建角色
语法: create role 角色名;
例子: create role testRole;
--授权角色
语法: grant select on class to 角色名;
列子: grant select on class to testRole;
--删除角色
语法: drop role 角色名;
例子: drop role testRole;
--授权dba角色
grant dba to NF_NFZC
===========================================导入导出===============================================================
--从源数据库导出:
exp user1/pwd@server1 file=c:\temp\exp.dmp tables=(table1, table2)
导入到标数据库:
imp user2/pwd@server2 file=c:\temp\exp.dmp tables=(table1, table2)
---exp 导出表
exp NF_NFZC/NF_NFZC@XE file=/u01/IGIS_LOCATION_COPY.dmp tables=IGIS_LOCATION_COPY log=/u01/IGIS_LOCATION_COPY.log
imp 导入表(按用户导入)
imp SBZS/SBZS@XE file=/u01/IGIS_LOCATION_COPY.dmp FROMUSER=NF_NFZC TOUSER=SBZS tables=IGIS_LOCATION_COPY
---expdp 导出表
select * from dba_directories;
--创建数据导出目录expnc_dir为目录名
create directory expnc_dir as 'E:\ncdatabak';
--为oracle用户授予访问数据目录的权限
Grant read,write on directory expnc_dir to dxzyjt;
--导出表
expdp system/Foresee_4U@nfzcdb tables=HX_DJ.dj_nsrxx dumpfile=djnsrxx.dmp directory=DMP;
--导入表从HX_DJ导入SBZS用户下面
impdp system/123456 DIRECTORY=DATA_PUMP_DIR DUMPFILE=djnsrxx.dmp REMAP_SCHEMA=HX_DJ:SBZS;
--字符集问题排查:http://www.cnblogs.com/lishupeng/p/5605558.html
--数据泵倒数据总结
一、导出
--1)导出用户
expdp scott/tiger@orcl schemas=scott dumpfile=expdp.dmp directory=oracleBak_dir
--2)导出表
expdp scott/tiger@orcl tables=emp,dept dumpfile=expdp.dmp directory=oracleBak_dir
--3)按查询条件导
expdp scott/tiger@orcl directory=oracleBak_dir dumpfile=expdp.dmp tables=emp query=’where deptno=20’
--4)按表空间导
expdp system/manager@orcl directory=oracleBak_dir dumpfile=tablespace.dmp tablespaces=temp,example
--5)导整个数据库
expdp system/manager@orcl directory=oracleBak_dir dumpfile=full.dmp full=y
二、导入数据
--1)导入用户(从用户scott导入到用户scott)
impdp scott/tiger@orcl directory=oracleBak_dir dumpfile=expdp.dmp schemas=scott
--2)导入表(从scott用户中把表dept和emp导入到system用户中)
impdp system/manager@orcl directory=oracleBak_dir dumpfile=expdp.dmp tables=scott.dept,scott.emp remap_schema=scott:system
--3)导入表空间
impdp system/manager@orcl directory=oracleBak_dir dumpfile=tablespace.dmp tablespaces=example
--4)导入数据库
impdb system/manager@orcl directory=oracleBak_dir dumpfile=full.dmp full=y
--5)追加数据
impdp system/manager@orcl directory=dump_dir dumpfile=expdp.dmp schemas=systemtable_exists_action
三、并行导出
expdp system/Foresee_4U@nfzcdb tables=HX_DJ.dj_nsrxx dumpfile=djnsrxx_%U.dmp directory=DMP;
--注意:dumpfile 参数拥有一个通配符 %U,它指示文件将按需要创建,格式将为expCASES_nn.dmp,其中nn 从 01 开始,然后按需要向上增加。
==========================================查看字符集=============================================================
select userenv('language') from dual;
==========================================表空间================================================================
set linesize 300;
set pagesize 300;
set timing on;
--Look TableSpace Use
--查看表空间方法一:
select ff.*, ff.maxsize_gb-ff.used_gb as sygb from (
select tablespace_name,
round(used_space*(select value from v$parameter where name='db_block_size')/power(2,30),2) USED_GB,
round(tablespace_size*(select value from v$parameter where name='db_block_size')/power(2,30)) MAXSIZE_GB,
round(used_percent,2) as "PCT%"
from dba_tablespace_usage_metrics
) ff where ff."PCT%" >60 order by ff."PCT%" desc;
--查看表空间方法二:
select tbs_used_info.tablespace_name,
tbs_used_info.alloc_mb,
tbs_used_info.used_mb,
tbs_used_info.max_mb,
tbs_used_info.free_of_max_mb,
tbs_used_info.used_of_max as "used_of_max_pct%"
from (select a.tablespace_name,
round(a.bytes_alloc / 1024 / 1024 / 1024) alloc_mb,
round((a.bytes_alloc - nvl(b.bytes_free, 0)) / 1024 / 1024 / 1024) used_mb,
round((a.bytes_alloc - nvl(b.bytes_free, 0)) * 100 /
a.maxbytes) used_of_max,
round((a.maxbytes - a.bytes_alloc + nvl(b.bytes_free, 0)) /
1024 / 1024 / 1024) free_of_max_mb,
round(a.maxbytes / 1024 / 1024 / 1024) max_mb
from (select f.tablespace_name,
sum(f.bytes) bytes_alloc,
sum(decode(f.autoextensible,
'YES',
f.maxbytes,
'NO',
f.bytes)) maxbytes
from dba_data_files f
group by tablespace_name) a,
(select f.tablespace_name, sum(f.bytes) bytes_free
from dba_free_space f
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name(+)) tbs_used_info where tbs_used_info.used_of_max>10
order by tbs_used_info.used_of_max desc;
-- Look TableSpace Path 查看表空间路径
-- select * from dba_data_files f where f.TABLESPACE_NAME='TS_SSSL_DAT_2018';
-- Extend TablesSpace 扩展表空间
-- ALTER TABLESPACE TS_SSSL_DAT_2018 ADD DATAFILE '+DSDATA/snltnfzc/datafile/ts_sssl_dat_35.dbf' SIZE 30G AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED;
--创建表空间
CREATE TABLESPACE SBZS_DATA
LOGGING
DATAFILE '/u01/app/oracle/oradata/XE/SBZS_DATA001.DBF'
SIZE 50M
AUTOEXTEND ON
NEXT 50M MAXSIZE 20480M
EXTENT MANAGEMENT LOCAL;
CREATE TABLESPACE TS_HX_DJ_DATA
LOGGING
DATAFILE '/u01/app/oracle/oradata/XE/TS_HX_DJ_DATA001.DBF'
SIZE 50M
AUTOEXTEND ON
NEXT 50M MAXSIZE 20480M
EXTENT MANAGEMENT LOCAL;
CREATE TABLESPACE NFZC_DATA
LOGGING
DATAFILE '/u01/app/oracle/oradata/XE/NFZC_DATA001.DBF'
SIZE 50M
AUTOEXTEND ON
NEXT 50M MAXSIZE 20480M
EXTENT MANAGEMENT LOCAL;
---查看表空间
select username,default_tablespace from dba_users;
---如果想要修改用户的永久表空间可以执行命令:
alter user user default tablespace tablespaceName;
例如:alter user SBZS default tablespace SBZS_DATA --其中第二个user为要操作的用户,tablespaceName为将要设置的默认表空间名称。
---如果想修改新添加的用户的默认表空间可以执行如下命名:
alter database default tablespace tablespaceName,这样新建立的用户的默认表空间就为tablespaceName
--根据存储过程内容查找存储过程名称
select * from all_source f where f.type='PROCEDURE' and f.text like '%%';
--更改表空间为SBZS_DATA
alter table SBZS.DJ_NSRXX move tablespace SBZS_DATA;
--针对某个用户设置默认表空间
alter user user_name default tablespace tbs_name;
Oracle 笔记总结
猜你喜欢
转载自blog.csdn.net/qq_30831237/article/details/85274353
今日推荐
周排行