oracle学习 四(持续更新中)无法为表空间 MAXDATA 中的段创建 INITIAL 区

解决建立表的时候出现的

ORA-01658: 无法为表空间 MAXDATA 中的段创建 INITIAL 区 

出现这个问题是因为表空间的大小不足,可以给他扩容这样的话也会多出来一个数据文件。具体写法如下:

ALTER TABLESPACE 表空间的名字  ADD DATAFILE '表空间的路径' SIZE 1000M;

当查询表空间的路径的时候可以使用以下oracle自带的系统表查询

select * from dba_data_files where tablespace_name = 'USER_DATA'

其中,where条件后面的是要查询的表空间的名字。

查询表空间的总大小,使用了多少,剩下多少以及使用百分比可以使用以下语句

select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",
round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
from
(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc;

查询数据文件的的总大小total_space 

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

查询用户所在哪个表空间的信息:

select * from dba_users;

 建表语句:

create table T_user_info
(
  user_id   number,
  user_name nvarchar2(50)
)
tablespace USER_DATA
  storage
  (
    initial 64K
    maxextents unlimited
  );

 语句建表之后切记一定要给他它指定表空间

原文地址:https://www.cnblogs.com/llcdbk/p/4195558.html