导入导出心得.....
导入导出问题...我自己弄了2天,但是还没解决,不知道什么办了.............................................................
---创建表空间
CREATE SMALLFILE TABLESPACE "HIS_DATA"
DATAFILE 'E:\DEVELOP\ORACLE\PRODUCT\10.2.0\ORADATA\DBBJYY\HIS_DATA.DBF' SIZE 1024M
AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
NOLOGGING EXTENT MANAGEMENT
LOCAL SEGMENT SPACE MANAGEMENT AUTO
CREATE SMALLFILE TABLESPACE "CHS_DATA"
DATAFILE 'D:\oracle\product\10.2.0\oradata\DBTDYY\CHS_DATA.dbf' SIZE 521M
AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
NOLOGGING EXTENT MANAGEMENT
LOCAL SEGMENT SPACE MANAGEMENT AUTO
----临时表空间
CREATE SMALLFILE TEMPORARY TABLESPACE "HIS_DATA_TEMP"
TEMPFILE 'D:\oracle\product\10.2.0\oradata\DBTDYY\HIS_DATA_TEMP.dbf' SIZE 1024M
AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 5M
CREATE SMALLFILE TEMPORARY TABLESPACE "CHS_DATA_TEMP"
TEMPFILE 'D:\oracle\product\10.2.0\oradata\DBTDYY\CHS_DATA_TEMP.dbf' SIZE 521M
AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 5M
=========================================================================================================================
--删除临时表空间:
DROP TABLESPACE temp001 INCLUDING CONTENTS AND DATAFILES;
---注释:
1) DATAFILE: 表空间数据文件存放路径
2) SIZE: 起初设置为200M
3) UNIFORM: 指定区尺寸为128k,如不指定,区尺寸默认为64k
4) 空间名称temp001 与 数据文件名称 temp001.dbf 不要求相同,可随意命名
5) AUTOEXTEND ON/OFF 表示启动/停止自动扩展表空间
6) ALTER DATABASE DATAFILE '/opt/oracle/oradata/orcl/temp001.dbf' RESIZE 500m; //手动修改
数据文件大小为500M
=======================================================================================================================
删除用户:drop user ×× cascade
说明: 删除了user,只是删除了该user下的schema objects,是不会删除相应的tablespace的。
删除表空间: 删除tablespace
DROP TABLESPACE tablespace_name INCLUDING CONTENTS AND DATAFILES
=======================================================================================================================
导入的时候仍然报该错误。
使用imp file=xxx.dmp indexfile=indxxx.sql生成sql文件,加上FULL=Y
然后使用记事本打开工具打开sql文件。把初始化参数的值设置为最小然后去掉rem的注释。
最后运行该语句。最终表结构成功建立。
===========================================================================================================================
查看表空间大小,剩余多少
SELECT UPPER(F.TABLESPACE_NAME) "表空间名",
D.TOT_GROOTTE_MB "表空间大小(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') || '%' "使用比",
F.TOTAL_BYTES "空闲空间(M)",
F.MAX_BYTES "最大块(M)"
FROM (SELECT TABLESPACE_NAME,
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 1;
===========================================================================================================================
--为表空间增加数据文件:
alter tablespace HIS_DATA add datafile 'E:\DEVELOP\ORACLE\PRODUCT\10.2.0\ORADATA\DBBJYY\HIS_DATA.DBF' size 4024M;
--查看表空间是否是大小文件
select bigfile from dba_tablespaces where tablespace_name='HIS_DATA'
--增加表空间原有数据文件尺寸:
alter database datafile 'E:\DEVELOP\ORACLE\PRODUCT\10.2.0\ORADATA\DBBJYY\HIS_DATA.DBF' resize 4090M;
--表空间打开自动增长
ALTER DATABASE DATAFILE 'E:\DEVELOP\ORACLE\PRODUCT\10.2.0\ORADATA\DBBJYY\HIS_DATA.DBF' AUTOEXTEND ON
---表空间自动增长200再大也不会超过1024
ALTER DATABASE DATAFILE 'E:\DEVELOP\ORACLE\PRODUCT\10.2.0\ORADATA\DBBJYY\HIS_DATA.DBF' AUTOEXTEND ON NEXT 500M MAXSIZE 1024M;
--查看表空间是否自动增长
SELECT FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE FROM dba_data_files
===============================================================================================================================
--创建用户
CREATE USER "JXCHS" PROFILE "DEFAULT" IDENTIFIED BY "jxchs" DEFAULT TABLESPACE "CHS_DATA" TEMPORARY TABLESPACE "CHS_DATA_TEMP" ACCOUNT UNLOCK;
BEGIN
dbms_aqadm.grant_system_privilege(privilege=>'ENQUEUE_ANY', grantee=>'jxchs', admin_option=>FALSE);
COMMIT;
END;
GRANT SELECT ANY TABLE TO "JXCHS";
GRANT UNLIMITED TABLESPACE TO "JXCHS";
GRANT "CONNECT" TO "JXCHS";
GRANT "DBA" TO "JXCHS";
-----------------------------------------------------
CREATE USER "DATA_SRC" PROFILE "DEFAULT" IDENTIFIED BY "DATA_SRC" DEFAULT TABLESPACE "HIS_DATA" TEMPORARY TABLESPACE "HIS_DATA_TEMP" ACCOUNT UNLOCK;
BEGIN
dbms_aqadm.grant_system_privilege(privilege=>'ENQUEUE_ANY', grantee=>'DATA_SRC', admin_option=>FALSE);
COMMIT;
END;
GRANT SELECT ANY TABLE TO "DATA_SRC";
GRANT UNLIMITED TABLESPACE TO "DATA_SRC" ;
GRANT "CONNECT" TO "DATA_SRC";
GRANT "DBA" TO "DATA_SRC";
-------------------------------------------------------
--命令行数据导入导出
--导出数据 完全导出 加上compress=n
exp system/manager@TEST file=d:\daochu.dmp full=y
--数据库下 某用户的数据全部导出
exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys) log=d:\daochu.log
--exp help=y 导出帮助
--导入数据 完全导入.
imp system/manager@TEST file=d:\daoru.dmp
--某用户下数据导入加忽略错误 IGNORE=Y
imp jxchs/jxchs@DBBJYY full=y file=C:\Users\houqijun\Desktop\sinosoft\date\bj_orcale\bjzxyy_jxchs_20130201.dmp ignore=y
imp DATA_SRC/DATA_SRC@DBBJYY full=y file=C:\Users\houqijun\Desktop\sinosoft\date\bj_orcale\bjzxyy_data_src_20130201.dmp ignore=y
--只导入表
imp data_src/data_src@DBBJYY file=C:\Users\houqijun\Desktop\sinosoft\date\table\MV_ORDERS_COSTS.dmp tables=(MV_ORDERS_COSTS)
导出某用户下表
exp jxchs/jxchs@dbbjyy file=d:\daoru.dmp tables= pub_manage_user
--imp help=y 导入帮助
----oracleServiceXXX在管理服务中没有的情况下创建
----oradim -new -sid DBXXX
----oradim -startup -sid DBXXX
--遇到ora-12560:tns:protocol abapter error为该监听程序提供的信息正由此计算机上的其他软件使用,如何解决冲突问题解决方案
运行cmd输入lsnrctl ---输入 stop 再输入 start
----select status,T.* from user_indexes T --查看用户索引状态条件可加表 where table_name='TABLE1' 发现status='INVALID'为索引失效
----创建job刷索引的方法
begin
execute immediate 'alter index ind_1 rebuild ';
execute immediate 'alter index ind_2 rebuild ';
execute immediate 'alter index ind_3 rebuild ';
end ;
---索引间隔trunc(sysdate+1,'DD')+1/24 --为每天
---查看索引是否失效
select status, T.* from user_indexes T;
select index_name, partition_name, status from user_ind_partitions;
select * from v$object_usage;
SELECT 'alter index ' || owner || '.' || index_name || ' rebuild online;',
status
FROM dba_indexes;
select t.Index_Name, t.Partition_Name, t.Tablespace_Name, t.Status
from Dba_Ind_Partitions t;
SELECT * FROM DBA_IND_PARTITIONS;
create index 定义索引名称 on 表名 (字段名); //创建索引
-------------强制删除运行中job
当Job的任务正在执行的时候,drop这个job并不能中止这个任务,需要通过它的sid来中止。步骤如下:
1.SELECT * FROM DBA_JOBS_RUNNING获得SID,
2.SELECT * FROM V$SESSION WHERE SID = sid获得对应的sid 和serial#,
3.ALTER SYSTEM KILL SESSION 'sid,serial#'就可以中止正在执行的任务。
--删除用户
select * from dba_users
drop user data_src cascade
----删除已链接用户
select username,sid,serial# from v$session
alter system kill session'142,5'
select tablespace_name,sum(bytes)/1024/1024 m from dba_free_space group by tablespace_name;
select file_name from dba_data_files;
alter tablespace his_data add datafile 'd:\oracle\product\10.2.0\oradata\dbhouse\his_data01.dbf' size 10g autoextend on next 1g;--扩展表空间
alter tablespace chs_data add datafile 'd:\oracle\product\10.2.0\oradata\dbhouse\chs_data101.dbf' size 10g autoextend on next 1g;
-------停运行中job
select * from dba_jobs_running;
SELECT spid FROM V$SESSION s,v$process v where s.PADDR=v.ADDR and sid='120'
orakill dbhouse spid
----------------注明-----------------------西京医院有个奇怪的问题 创建job的时候
CREATE MATERIALIZED VIEW DD_CURRENT_PRICE_LIST
REFRESH FORCE ON DEMAND
WITH ROWID
NEXT TRUNC(SYSDATE+1,'DD')+1/24
AS
SELECT * from CURRENT_PRICE_LIST@dblink_his.com;
------------创建不了
AS
select * from (SELECT * from CURRENT_PRICE_LIST@dblink_his.com); ------可以创建 不知道什么问题
----em登录
http://localhost:1158/em
---查询目前连接数
show parameter processes;
---更改系统连接数
alter system set processes=1000 scope=both; --可以写入文件
alter system set processes = 300 scope = spfile;
alter system set job_queue_processes=10 scope=spfile;
alter system register
---创建pfile
create pfile from spfile;
---查询Oracle会话的方法
select * from v$session