1. 导出dmp 文件
(1)导出数据库所有的用户数据:
exp system/manage@ORCL file=D:\oracle_dmp\data1.dmp full=y
(2)导出指定的用户数据:
exp system/manage@ORCL file=D:\oracle_dmp\data1.dmp owner=(system,sys)
(3)导出指定的表数据:
exp system/manage@ORCL file=D:\oracle_dmp\data1.dmp table=(T_BASE_USER,T_BASE_DEPT)
2.导入dmp 文件
(1)创建表空间信息:
create tablespace DATA_INDB datafile 'D:\jgbs_db\DATA_INDB.DBF' size 1024M autoextend on;
若是导入的文件信息过大 则需要添加对应的扩展:
ALTER TABLESPACE DATA_INDB ADD DATAFILE 'D:\jgbs_db\DATA_INDB_02.DBF' SIZE 1G AUTOEXTEND ON NEXT 1G MAXSIZE 30G;
(2)创建用户以及授权:
create user INDBADMIN_FISP identified by INDBADMIN_FISP default tablespace DATA_INDB temporary tablespace temp;
grant dba to INDBADMIN_FISP;
(3)创建虚拟文件夹(dmp保存的路径地址)以及授权给创建的用户:
create or replace directory data as 'D:\jgbs_db';
grant read,write on directory data to INDBADMIN_FISP;
(4)通过impdp导入文件信息(remap_schema,remap_tablespace 中第一个为参数为原用户和原空间信息,第二个参数为新建的用户和新表空间信息)
impdp INDBADMIN_FISP/INDBADMIN_FISP directory=data dumpfile=jgbb_fisp.dmp remap_schema=INDBADMIN_FISP:INDBADMIN_FISP remap_tablespace=DATA_INDB_FISP:DATA_INDB
3.同义词
(1)查询失效的同义词:
select 'drop ' || decode(s.owner,'PUBLIC','public synonym ','synonym ' || s.owner || '.') || s.synonym_name || ';' as "Dropping invalid synonyms:"
from dba_synonyms s
where table_owner not in ('SYSTEM', 'SYS')
and db_link is null
and not exists (select null from dba_objects o where s.table_owner = o.owner and s.table_name = o.object_name);
(2)相同ip下创建同义词:
create or replace synonym TC_MK_BZZQPJXXB for MK_DB.TC_MK_BZZQPJXXB;
(3)不同ip下创建同义词:
--创建db_link
CREATE DATABASE LINK link_mk_db
CONNECT TO MK_DB_FISP IDENTIFIED BY MK_DB_FISP
USING '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST =172.16.11.2)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = dbtest4)))';
--验证link 是否成功
select * from dual@link_mk_db;
select * from TC_MK_COMPANYINFO @link_mk_db;
--创建同义词
create synonym TC_MK_COMPANYINFO for TC_MK_COMPANYINFO@link_mk_db ;
4,查看表空间使用状况:
SELECT a.tablespace_name "表空间名",
total/1024/1024 "表空间大小单位M",
free/1024/1024 "表空间剩余大小单位M",
(total - free)/1024/1024 "表空间使用大小单位M",
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;
5,查询该用户下表大小:
SELECT
table_name,
nvl ( bytes, 0 ),
nvl ( bytes / 1024, 0 ) KB,
nvl ( bytes / 1024 / 1024, 0 ) MB
FROM
dba_tables
LEFT JOIN dba_segments ON table_name = segment_name
AND segment_type = 'TABLE' -- 如果是分区表, 则 segment_type = 'TABLE PARTITION'
AND dba_segments.OWNER = 'INDBADMIN_FISP'
WHERE
dba_tables.OWNER = 'INDBADMIN_FISP'
ORDER BY
nvl ( bytes, 0 ) DESC
6,查询用户下的所有表:
select * from all_tables where owner='TEST';
7,查询当前登录的用户所拥有的表:
select table_name from user_tables;
手机扫一扫
移动阅读更方便
你可能感兴趣的文章