惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
U
Unit 42
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
L
LangChain Blog
Engineering at Meta
Engineering at Meta
量子位
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
A
About on SuperTechFans
Y
Y Combinator Blog

博客园 - kagar

挖掘经典:几乎被人遗忘的HTML七种用法 【转】P2P穿透NAT原理 关于delphi调用.net com的详细过程 3desj加密 C++ ,C#类型对照 DLL+ ActiveX控件+WEB页面调用例子 测试 Sql Server2005不同的表使用不同的表空间 Office文档在线编辑的实现之二 如何在Web页面上直接打开、编辑、创建Office文档 Foursquare引爆了什么 承博士:让云计算落地生根的中国云计算平台 PHP - Smarty 工作流系统功能列表系列 跨域情况下Iframe高度自适应解决方案 - kagar - 博客园 五种丑陋的项目管理 Chart 报表 jQuery 数据仓库与事务型数据库的区别 RUP与XP的平衡之道
表空间
kagar · 2010-05-24 · via 博客园 - kagar

创建临时表空间:

CREATE TEMPORARY TABLESPACE TEMP TEMPFILE'\data1\TEMP01.dbf' SIZE 500M autoextend on next 10M;

alter table AVG_ONLINE_USR move   tablespace  TBS_ubis_NEWEBA2;

alter user xm default tablespace tablespace_name

查看用户默认的表空间.sql:

select username,default_tablespace from dba_users;

查看各个表空间占用磁盘情况.sql:

select 
b.file_id 文件ID号, 
b.tablespace_name 表空间名, 
b.bytes/1024/1024||'M'字节数, 
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024||'M' 已使用, 
sum(nvl(a.bytes,0))/1024/1024||'M' 剩余空间, 
100 - sum(nvl(a.bytes,0))/(b.bytes)*100 占用百分比 
from dba_free_space a,dba_data_files b 
where a.file_id=b.file_id 
group by b.tablespace_name,b.file_id,b.bytes 
order by b.file_id 

以上2者关联,就是查看用户默认表空间使用情况的sql语句:

Select *
FROM 
      (select username,default_tablespace from dba_users) ut,
      (select 
      --b.file_id 文件ID号, 
      b.tablespace_name 表空间名, 
      b.bytes/1024/1024||'M'字节数, 
      (b.bytes-sum(nvl(a.bytes,0)))/1024/1024||'M' 已使用, 
      sum(nvl(a.bytes,0))/1024/1024||'M' 剩余空间, 
      100 - sum(nvl(a.bytes,0))/(b.bytes)*100 占用百分比 
      from dba_free_space a,dba_data_files b 
      where a.file_id=b.file_id 
      group by b.tablespace_name,b.file_id,b.bytes 
      order by b.file_id ) tsu
Where ut.default_tablespace = tsu.表空间名
orDER BY ut.username

怎么查看某个表空间里的数据文件的名称和大小?
select * from dba_data_files;

增大表空间的两种方法:

1.增加额外的数据文件到表空间中

  例如:alter tablespace users add datafile '/u01/oradata/orcl/users02.dbf' size 25m;

2.修改表空间当前的数据文件

  例如:alter database datafile '/u01/oradata/orcl/users01.dbf' resize 50m;

例如:

 alter database datafile 'G:\ORACLE\PRODUCT\10.2.0\ORADATA\NXTMSG\USERS01.DBF' resize 300m;

create tablespace ** datafile ** size **

create user ** identified by ** default tablespace ** 
 

查看临时表空间的大小和使用情况:
Select round((f.bytes_free + f.bytes_used) / 1024 / 1024, 2) "total MB",
       round(((f.bytes_free + f.bytes_used) - nvl(p.bytes_used, 0)) / 1024 / 1024, 2)  "Free MB" ,
       d.file_name "Datafile name",
       round(nvl(p.bytes_used, 0)/ 1024 / 1024, 2) "Used MB",
       round((f.bytes_free + f.bytes_used) / 1024, 2) "total KB",
       round(((f.bytes_free + f.bytes_used) - nvl(p.bytes_used, 0)) / 1024, 2)  "Free KB",
       round(nvl(p.bytes_used, 0)/ 1024, 2) "Used KB",
       0 "Fragmentation Index"
from   SYS.V_$TEMP_SPACE_HEADER f, DBA_TEMP_FILES d, SYS.V_$TEMP_EXTENT_POOL p
where  f.tablespace_name(+) = d.tablespace_name
and    f.file_id(+) = d.file_id
and    p.file_id(+) = d.file_id