Oracle tablespace

knowledge is accumulated

Relying on the accumulation and development is to comb and summarize, fighting~

 -------------------------------------------------- tablespace ------------------------------------------------ --------

*, view the name of the oracle tablespace and its used size (M)

SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size_M
FROM dba_tablespaces t, dba_data_files d
WHERE t.tablespace_name = d.tablespace_name
GROUP BY t.tablespace_name;

 

*, View the physical file path corresponding to the Oracle tablespace name and its used size

SELECT tablespace_name,
file_name,
round(bytes / (1024 * 1024), 0) total_space_M
FROM dba_data_files
ORDER BY tablespace_name;

 

*, query the free size M of the oracle tablespace

SELECT SUM(bytes) / (1024 * 1024) AS free_space_M, tablespace_name
FROM dba_free_space
GROUP BY tablespace_name;

 

*, query the occupancy ratio of oracle table space

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;

 

*, Query the information of table partitions, tables, views, sequences, stored procedures, triggers, java resources, etc. of oracle library objects

SELECT owner, object_type, status, COUNT(*) count#
FROM all_objects
GROUP BY owner, object_type, status;

 

*, query the version information of oracle and its components

SELECT product,version from product_component_version;

 

*, view the creation date of oracle and its filing method

SELECT created, log_mode, log_mode FROM v$database;

 

*, eg: View table space usage (reference)

SELECT a.tablespace_name "tablespace name",
total "tablespace size",
free "table space remaining size",
(total - free) "Tablespace usage size",
total / (1024 * 1024 * 1024) "Table space size (G)",
free / (1024 * 1024 * 1024) "Remaining size of table space (G)",
(total - free) / (1024 * 1024 * 1024) "Table space usage size (G)",
round((total - free) / total, 4) * 100 "Usage %"
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

 

*, oracle create tablespace

create tablespace caetestspace  
datafile 'D:\App\oracle11r2\caedbf\caetestspace.dbf'   
size 1500M   
autoextend on next 50M maxsize 3000M;

 

*, Oracle creates a temporary table space (oracle's own cannot meet the demand)

create temporary tablespace caetesttempspace  
tempfile 'D:\App\oracle11r2\caedbf\caetesttempspace.dbf'   
size 500M   
autoextend on next 50M maxsize unlimited;

*, Query the physical file and its location corresponding to a table space in Oracle

select * from dba_data_files where tablespace_name='USERS';

 

*, Oracle table space to add data files

alter tablespace caetest add datafile 'd:\newtablespacefile.dbf' size 500m;

 

*, oracle delete (temporary) tablespace

drop tablespace testtempspace including contents and datafiles cascade constraints;

    没有drop temporyary的用法

 

 

  --------------------------------------------------表空间和表的关系--------------------------------------------------------

*、oracle查询某个表空间下有哪些表

select tablespace_name,table_name from user_tables;

 

  --------------------------------------------------数据库用户--------------------------------------------------------

*、oracle管理员查询数据库中用户信息

select username from dba_users;

 

*、oracle创建用户

create user caetest identified by caetest;

 

*、 oracle查看用户拥有的权限

select * from dba_role_privs;
select * from user_role_privs;

 

*、oracle用户授予权限

grant resource , connect to caetest;

 

*、oracle用户收回权限

revoke resource , connect from caetest;

 

*、oracle为已存在的用户赋予表空间以及临时表空间(临时可有可无,但需要时必须这样写)

alter user caetest identified by caetest default tablespace caetestspace temporary tablespace caetesttempspace;

 

*、oracle查看当前用户默认表空间

select username,default_tablespace from user_users;

 

*、oracle查看所有用户默认表空间

select username,default_tablespace from dba_users;

 

*、oracle删除用户

drop user caetest cascade;

 

   --------------------------------------------------资源链接--------------------------------------------------------

感谢以下资源的分享者(更详尽):

oracle用户、权限、角色的梳理

http://www.cnblogs.com/chenleiustc/archive/2009/07/29/1534110.html(访问速度快)

用户及表空间的管理

http://blog.csdn.net/starnight_cbj/article/details/6792364

临时表空间的增删查改以及PGA和临时表空间的使用策略

http://www.cnblogs.com/guanjie20/p/3858480.html

oracle实例的内存(SGA和PGA)的查询和调整

http://log-cd.iteye.com/blog/562052

修改oracle服务端字符集编码(慎用)

http://blog.csdn.net/fred_yang2013/article/details/46679931

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326571447&siteId=291194637