今天在访问项目时意外发生了500错误,本地自检发现控制台出现了“ ORA-01653: 表 MIS.X 无法通过 8 (在表空间 MIS_TBSPACE 中) 扩展”错误。
2021-03-09 09:38:30,980 [http-nio-8081-exec-4] WARN [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] - Resolved exception caused by Handler execution: org.springframework.jdbc.UncategorizedSQLException:
### Error updating database. Cause: java.sql.SQLException: ORA-01653: 表 MIS.ATTENDANCE_REPORT 无法通过 8 (在表空间 MIS_TBSPACE 中) 扩展
### The error may involve com.qkxx.web.modules.attendance.mapper.AttendanceReportMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO attendance_report ( id, attendance_user_id, attendance_user_name ) VALUES ( ?, ?, ? )
### Cause: java.sql.SQLException: ORA-01653: 表 MIS.ATTENDANCE_REPORT 无法通过 8 (在表空间 MIS_TBSPACE 中) 扩展
; uncategorized SQLException; SQL state [72000]; error code [1653]; ORA-01653: 表 MIS.ATTENDANCE_REPORT 无法通过 8 (在表空间 MIS_TBSPACE 中) 扩展
; nested exception is java.sql.SQLException: ORA-01653: 表 MIS.ATTENDANCE_REPORT 无法通过 8 (在表空间 MIS_TBSPACE 中) 扩展
/*创建用户*/
create user chengxuyuan by 123;
/*创建表空间*/
create tablespace db_tbspace datafile 'E:\dbspace\db_data.dbf' size 100M;
/*分配表空间*/
alter user CHENGXUYUAN default tablespace db_tbspace ;
/*分配权限*/
grant create session,create table,create view,create sequence,unlimited tablespace to CHENGXUYUAN ;
/*查询用户权限*/
select *from session_privs;
/*删除用户*/(慎用)
drop user CHENGXUYUAN cascade;
可以看到当时表空间分配只划分了100M的空间,现数据量太大已经无法满足要求,现将解决方案记录如下:
1、使用DBA权限登陆
打开SQL PLUS 命令窗口,使用SYSTEM账号登陆
请输入用户名: system
输入口令:
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
如果忘记密码(不曾修改的话),可以尝试以下密码:
其中Oracle的sys和system默认密码
system默认:manager
sys默认:change_on_install
使用SQL Plus登录数据库时,system使用密码manager可直接登录。
但如果是sys用户,密码必须加上as sysdba,即完整密码为:change_on_install as sysdba
2、查看所有的表空间
SQL> select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
EXAMPLE
MIS_TBSPACE
除了默认的表空间之外,此处可以看到我自己的表空间为“MIS_TBSPACE”
注:如果找不到自己表空间的位置,可以使用以下命令:
SQL> select * from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------------------------------------
BYTES BLOCKS STATUS RELATIVE_FNO AUTOEX MAXBYTES
---------- ---------- ------------------ ------------ ------ ----------
MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS
---------- ------------ ---------- ----------- --------------
C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
4 USERS
5242880 640 AVAILABLE 4 YES 3.4360E+10
4194302 160 4194304 512 ONLINE
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------------------------------------
BYTES BLOCKS STATUS RELATIVE_FNO AUTOEX MAXBYTES
---------- ---------- ------------------ ------------ ------ ----------
MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS
---------- ------------ ---------- ----------- --------------
C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
3 UNDOTBS1
104857600 12800 AVAILABLE 3 YES 3.4360E+10
4194302 640 103809024 12672 ONLINE
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------------------------------------
BYTES BLOCKS STATUS RELATIVE_FNO AUTOEX MAXBYTES
---------- ---------- ------------------ ------------ ------ ----------
MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS
---------- ------------ ---------- ----------- --------------
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
2 SYSAUX
933232640 113920 AVAILABLE 2 YES 3.4360E+10
4194302 1280 932184064 113792 ONLINE
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------------------------------------
BYTES BLOCKS STATUS RELATIVE_FNO AUTOEX MAXBYTES
---------- ---------- ------------------ ------------ ------ ----------
MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS
---------- ------------ ---------- ----------- --------------
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
1 SYSTEM
828375040 101120 AVAILABLE 1 YES 3.4360E+10
4194302 1280 827326464 100992 SYSTEM
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------------------------------------
BYTES BLOCKS STATUS RELATIVE_FNO AUTOEX MAXBYTES
---------- ---------- ------------------ ------------ ------ ----------
MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS
---------- ------------ ---------- ----------- --------------
C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
5 EXAMPLE
104857600 12800 AVAILABLE 5 YES 3.4360E+10
4194302 80 103809024 12672 ONLINE
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------------------------------------
BYTES BLOCKS STATUS RELATIVE_FNO AUTOEX MAXBYTES
---------- ---------- ------------------ ------------ ------ ----------
MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS
---------- ------------ ---------- ----------- --------------
C:\PROGRAM FILES\ORACLE\DBSPACE\MIS_DATA.DBF
6 MIS_TBSPACE
104857600 12800 AVAILABLE 6 NO 0
0 0 103809024 12672 ONLINE
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------------------------------------
BYTES BLOCKS STATUS RELATIVE_FNO AUTOEX MAXBYTES
---------- ---------- ------------------ ------------ ------ ----------
MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS
---------- ------------ ---------- ----------- --------------
C:\PROGRAM FILES\ORACLE\DBSPACE\MIS_DATA02.DBF
7 MIS_TBSPACE
1073741824 131072 AVAILABLE 7 YES 3.4360E+10
4194302 6400 1072693248 130944 ONLINE
已选择7行。
3、为表空间增加一个数据文件
这条语句的意思是 为表空间“MIS_TBSPACE” 在指定路径添加一个“,DBF”数据文件,文件可自动扩展,默认每次增加50M。
SQL> ALTER TABLESPACE "MIS_TBSPACE" ADD DATAFILE 'C:\Program Files\Oracle\dbspace\MIS_DATA02.DBF' SIZE 1G AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED;
表空间已更改。
另附可能会用到的一些命令:
1、查询所有表空间使用情况
SQL> SELECT UPPER(F.TABLESPACE_NAME) "表空间名",
2 D.TOT_GROOTTE_MB "表空间大小(M)",
3 D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
4 TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') "使用比",
5 F.TOTAL_BYTES "空闲空间(M)",
6 F.MAX_BYTES "最大块(M)"
7 FROM (SELECT TABLESPACE_NAME,
8 ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
9 ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES
10 FROM SYS.DBA_FREE_SPACE
11 GROUP BY TABLESPACE_NAME) F,
12 (SELECT DD.TABLESPACE_NAME,
13 ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
14 FROM SYS.DBA_DATA_FILES DD
15 GROUP BY DD.TABLESPACE_NAME) D
16 WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
17 ORDER BY 4 DESC;
表空间名 表空间大小(M)
------------------------------------------------------------ -------------
已使用空间(M) 使用比 空闲空间(M) 最大块(M)
------------- -------------- ----------- ----------
SYSTEM 790
780.06 98.74 9.94 9
SYSAUX 890
833.5 93.65 56.5 46
USERS 5
4.06 81.20 .94 .94
表空间名 表空间大小(M)
------------------------------------------------------------ -------------
已使用空间(M) 使用比 空闲空间(M) 最大块(M)
------------- -------------- ----------- ----------
EXAMPLE 100
78.75 78.75 21.25 18.81
UNDOTBS1 100
16.25 16.25 83.75 49
2、为表空间增加自动扩展能力
alter database datafile 'E:\app\Administrator\oradata\orcl\SYSTEM01.DBF' AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED;
3、查看表空间是否有自动扩展能力
SQL> SELECT T.TABLESPACE_NAME,D.FILE_NAME,
2 D.AUTOEXTENSIBLE,D.BYTES,D.MAXBYTES,D.STATUS
3 FROM DBA_TABLESPACES T,DBA_DATA_FILES D
4 WHERE T.TABLESPACE_NAME =D.TABLESPACE_NAME
5 ORDER BY TABLESPACE_NAME,FILE_NAME;
TABLESPACE_NAME
------------------------------------------------------------
FILE_NAME
--------------------------------------------------------------------------------
AUTOEX BYTES MAXBYTES STATUS
------ ---------- ---------- ------------------
EXAMPLE
C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
YES 104857600 3.4360E+10 AVAILABLE
MIS_TBSPACE
C:\PROGRAM FILES\ORACLE\DBSPACE\MIS_DATA.DBF
NO 104857600 0 AVAILABLE
TABLESPACE_NAME
------------------------------------------------------------
FILE_NAME
--------------------------------------------------------------------------------
AUTOEX BYTES MAXBYTES STATUS
------ ---------- ---------- ------------------
MIS_TBSPACE
C:\PROGRAM FILES\ORACLE\DBSPACE\MIS_DATA02.DBF
YES 1073741824 3.4360E+10 AVAILABLE
SYSAUX
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
TABLESPACE_NAME
------------------------------------------------------------
FILE_NAME
--------------------------------------------------------------------------------
AUTOEX BYTES MAXBYTES STATUS
------ ---------- ---------- ------------------
YES 933232640 3.4360E+10 AVAILABLE
SYSTEM
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
YES 828375040 3.4360E+10 AVAILABLE
UNDOTBS1
TABLESPACE_NAME
------------------------------------------------------------
FILE_NAME
--------------------------------------------------------------------------------
AUTOEX BYTES MAXBYTES STATUS
------ ---------- ---------- ------------------
C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
YES 104857600 3.4360E+10 AVAILABLE
USERS
C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
YES 5242880 3.4360E+10 AVAILABLE
已选择7行。