/*第1步:创建临时表空间 */
create temporary tablespace user_temp
tempfile 'D:\oracle\oradata\Oracle9i\user_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
/*第2步:创建数据表空间 */
create tablespace user_data
logging
datafile 'D:\oracle\oradata\Oracle9i\user_data.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
/*第3步:创建用户并指定表空间 */
create user username identified by 123456
default tablespace user_data
temporary tablespace user_temp;
/*第4步:给用户授予权限 */
grant connect,resource,dba to username;
grant all privileges TO CZNE;
/**查看表空间使用情况*/select * from (
Select a.tablespace_name,
to_char(a.bytes/1024/1024,'99,999.999') total_bytes,
to_char(b.bytes/1024/1024,'99,999.999') free_bytes,
to_char(a.bytes/1024/1024 - b.bytes/1024/1024,'99,999.999') use_bytes,
to_char((1 - b.bytes/a.bytes)*100,'99.99') || '%'use
from (select tablespace_name,
sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name,
sum(bytes) bytes
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
union all
select c.tablespace_name,
to_char(c.bytes/1024/1024,'99,999.999') total_bytes,
to_char( (c.bytes-d.bytes_used)/1024/1024,'99,999.999') free_bytes,
to_char(d.bytes_used/1024/1024,'99,999.999') use_bytes,
to_char(d.bytes_used*100/c.bytes,'99.99') || '%'use
from
(select tablespace_name,sum(bytes) bytes
from dba_temp_files group by tablespace_name) c,
(select tablespace_name,sum(bytes_cached) bytes_used
from v$temp_extent_pool group by tablespace_name) d
where c.tablespace_name = d.tablespace_name
)
order by tablespace_name
/**是否设置为自动扩展*/
SELECT FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE FROM dba_data_files;
1.增加数据文件
ALTER TABLESPACE game
ADD DATAFILE '/oracle/oradata/db/GAME02.dbf' SIZE 1000M;
2.手动增加数据文件尺寸
--数据表空间
ALTER DATABASE DATAFILE '/oracle/oradata/db/GAME.dbf'
RESIZE 4000M;
--临时表空间
ALTER DATABASE TEMPFILE 'D:\oracle\oradata\DENE_TEMP.DBF'
RESIZE 2048M;
3.设定数据文件自动扩展
ALTER DATABASE DATAFILE '/oracle/oradata/db/GAME.dbf
AUTOEXTEND ON NEXT 100M
MAXSIZE 10000M;
查询索引占用了多少表空间
Select Segment_Name, Sum(bytes) / 1024 / 1024/1024 as Gsize From User_Extents Group By Segment_Name order by Gsize desc
----------删除用户以及表空间----------
DROP USER DAEN cascade;
drop tablespace DENE_DATA including contents and datafiles cascade constraint;
--------------------------导入dmp数据文件---------------------------------------------
1、把xxx.dmp文件放入D:\oracle\app\Administrator\admin\orcl\dpdump目录下
2、impdp daan/123456 DIRECTORY=DATA_PUMP_DIR DUMPFILE=xxx.dmp REMAP_SCHEMA=xx_test:daan remap_tablespace=TS_xx_DATA:DAAN_DATA table_exists_action=skip logfile=implog.log
或者如果不知道表空间与用户名
impdp pangu/123456 DIRECTORY=DATA_PUMP_DIR DUMPFILE=daen0615.dmp TRANSFORM=SEGMENT_ATTRIBUTES:n table_exists_action=replace logfile=implog.log
or
impdp daen/asdqwe DIRECTORY=DATA_PUMP_DIR DUMPFILE=daen0615.dmp REMAP_SCHEMA="dene:daen" remap_tablespace="ANE_KD:DENE_DATA" remap_tablespace="TABLE_PERMANT:DENE_DATA" remap_tablespace="TS_ST_DATA:DENE_DATA" remap_tablespace="TABLE_STUDENT:DENE_DATA" remap_tablespace="TS_KJ_DATA:DENE_DATA" remap_tablespace="TS_SX_DATA:DENE_DATA" remap_tablespace="TABLE_TEST_HBH:DENE_DATA" remap_tablespace="TS_CJ_DATA:DENE_DATA" table_exists_action=replace logfile=implog.log
------------------------------windows 重启oracle
1、cmd进入
2、关闭:
lsnrctl stop
net stop OracleServiceORCL
3、开启:
lsnrctl start
net start OracleServiceORCL