1、数据统计信息
bash
1.设置并行收集
SQL> set timing on
SQL> exec dbms_stats.set_global_prefs('CONCURRENT','TRUE');
2.开始收集全库统计信息
begin
dbms_stats.gather_database_stats(ESTIMATE_PERCENT=>DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt => 'for all indexed columns', cascade=>true, degree=>120);
end;
/
3.关闭并行收集
SQL> exec dbms_stats.set_global_prefs('CONCURRENT','FALSE');
注意:如果执行第二步统计数据出现ORA-20000错误,可能需要关闭并行收集。
2.查询系统用户表,看数据条数是否已更新
bash
SELECT TABLE_NAME,NUM_ROWS FROM USER_TABLES WHERE TABLE_NAME LIKE 'T%' ORDER BY NUM_ROWS DESC;
SELECT TABLE_NAME,NUM_ROWS FROM DBA_ALL_TABLES WHERE TABLE_NAME LIKE 'T%' AND NUM_ROWS>0 ORDER BY NUM_ROWS DESC;
3.数据导入
bash
impdp userid=\'/ as sysdba\' directory=DUMP_DIR dumpfile=20240821_%U.dmp logfile=import.log CLUSTER=N parallel=6 table_exists_action=replace tables=table1,table2,table3
4.数据导出
bash
expdp \"/ as sysdba\" directory=DUMP_DIR dumpfile=20240821_%U.dmp parallel=6 logfile=exp_20240821.log schemas=USER1,USER2,USER3 compression=all CLUSTER=N
5.常规操作
bash
1.创建用户
create user username identified by passwd;
2.授权
grant connect,resource to username;
grant create session to username;
grant dba to username;
3.创建表空间
create tablespace ACCIDX
nologging
datafile '/home/oracle/oradata/orcl/ACCIDX.dbf' size 1000m autoextend on next 50m
maxsize unlimited
extent management local
uniform segment space
management
auto;
4.创建Directory对象
create or replace directory DUMP_DIR as '/home/oracle/dmpdata';
5.删除表空间
DROP TABLESPACE TA60ACCIDX INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;
6.删除用户
drop user ifm40 cascade;
7.修改密码
alter user ifm40 identified by hundsun;
8.重建视图
select 'CREATE OR REPLACE VIEW '||view_name||' AS ' ||TEXT_VC||';' FROM ALL_VIEWS WHERE OWNER ='NAME';
9.设置Linux主机名(非sql命令操作)
hostnamectl set-hostname ifm40
systemctl restart network
参考文章: