oracle中看表空间大小等
在网络上查过很多次表空间、表的大小等信息,老是记不住,还是记下来好了。
首先用户名system/manager
然后有:select * from dba_segments
哈哈,然后看了就会用了。网络上好像还说了很多
增加用户的quota
SELECT *
FROM dba_ts_quotas
WHERE username = 'DEVERS'
ALTER USER mapuser QUOTA UNLIMITED ON tbl_space;
analyze table 表可以看.
select table_name name, num_rows, blocks, empty_blocks, avg_space, chain_cnt, avg_row_len
,sample_size, last_analyzed
, user_stats, global_stats
from user_tables where table_name =' XXX '
或者
select * from dba_segments where owner='xxx' and segment_name='xxx'
另外还有表空间的常用操作,和增加用户的操作:
create tablespace emp
logging
datafile '/oracle/oradata/dba/emp.dbf' size 5M extent
扩展表空间
首先查看表空间的名字和所属文件
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
1.增加数据文件
ALTER TABLESPACE game
ADD DATAFILE '/oracle/oradata/db/GAME02.dbf' SIZE 1000M;
2.手动增加数据文件尺寸
ALTER DATABASE DATAFILE '/oracle/oradata/db/GAME.dbf'
RESIZE 4000M;
3.设定数据文件自动扩展
ALTER DATABASE DATAFILE '/oracle/oradata/db/GAME.dbf
AUTOEXTEND ON NEXT 100M
MAXSIZE 10000M;
设定后查看表空间信息
SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,
(B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"
FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;
创建用户
create user jackylau identified by richie default tablespace emp temporary
tablespace temp quota 15m on emp password expire;
授权用户
grant dba to jackylau with admin option;
alter user jackylau default role all;
感觉将来都用的到,先学习下。