Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Some operations of oracle about tablespaces

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Check to see if the xxx tablespace is automatically extended:

Select file_name,autoextensible,increment_by from dba_data_files

Select file_id,file_name,tablespace_name,autoextensible,increment_by from dba_data_files order by file_id desc

Turn on the tablespace automatic extension feature:

Alter database datafile'/ u01 autoextend on

View the data file size:

Select TABLESPACE_NAME,FILE_NAME,BYTES/1024/1024 M from dba_data_files order by TABLESPACE_NAME

Query the total capacity of the tablespace:

Select tablespace_name, sum (bytes) / 1024 / 1024 as MB

From dba_data_files

Group by tablespace_name

Query tablespace usage:

Select total.tablespace_name

Round (total.MB, 2) as Total_MB

Round (total.MB-free.MB, 2) as Used_MB

Round ((1-free.MB / total.MB) * 100,2) | |'%'as Used_Pct

From (select tablespace_name, sum (bytes) / 1024 / 1024 as MB

From dba_free_space

Group by tablespace_name) free

(select tablespace_name, sum (bytes) / 1024 / 1024 as MB

From dba_data_files

Group by tablespace_name) total

Where free.tablespace_name = total.tablespace_name

Expand the tablespace:

# first check the name and file and space of the tablespace

Select tablespace_name, file_id, file_name,round (bytes/ (1024,1024), 0) total_space from dba_data_files order by tablespace_name

# three expansion methods

1.alter tablespace test add datafile'/ u01Compact test02.dbf' size 10m (automatically add a datafile)

2.alter database datafile'/ u01Compact test.dbf' resize 20m

3.alter database datafile'/ u01Compact test.dbf' autoextend on next 10m maxsize 1G

View tablespace information after setting:

Select a.tablespacepurname.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 from sys.sm$ts_avail sys.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report