您的位置:首页 > 博客中心 > 数据库 >

oracle10g 空表无法导出导致项目报错—— 表或视图不存在

时间:2022-03-14 02:56

     今天下午将远程数据库中数据导出然后导入到本地数据库,部署的项目连接本地数据库后jboss启动后编译报如下错误:


     严重: Exception sending context initialized event to listener instance of class com.dicpsi.mis.contextListener.ContextListener
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy1.find(Unknown Source)
Caused by: java.sql.SQLException: ORA-00942: 表或视图不存在。


查找原因:通过报错信息表或试图不存在,我试图通过以上信息来定位相关的不存在的表,但是我没有找到这些不存在的表。然后,我打开远程数据库此用户的数据表和我导入的本地数据表做对比,发现导入本地数据库的表中少了8张在远程数据数据库中数据为空的表。


解决方法:最后我通过查找相关文档,通过以下sql语句重新导出远程数据服务器中存储数据为空的表。



--选出为空的字段
select ‘alter table ‘||table_name||‘ allocate extent(size 64k);‘ from tabs t     where not exists (select segment_name from user_segments s where s.segment_name=t.table_name);

注明:

oracle11g的新特性,数据条数是0时不分配segment,所以就不能被导出。执行以上sql后,将在查询内容中列举出所有存储数据为空的表,并生成如下sql语句,然后将以下内容复制黏贴出来执行。


--改变为空的表,让其导出数据库时识别
alter table PBCATVLD allocate extent(size 64k);
alter table PBCATTBL allocate extent(size 64k);
alter table PBCATCOL allocate extent(size 64k);
alter table MIS_WORDBOOKMARK allocate extent(size 64k);
alter table MIS_CHAT_SPARE allocate extent(size 64k);
alter table MIS_CHART allocate extent(size 64k);
alter table AS_TRANSRESULT_CHECKACCOUNT allocate extent(size 64k);
alter table AS_TRANSERRLOG allocate extent(size 64k);
alter table AS_BANKTRANSCOMPARE allocate extent(size 64k);
alter table AR_CUSTOMERINFO allocate extent(size 64k);

注明:执行完以上sql语句,原来远程数据库中存储数据为空的表将会被导出,只不过数据依旧为空。

导出数据库语句:

exp 用户名/密码@数据库实例名 file=/home/oracle/exp.dmp log=/home/oracle/exp_smsrun.log

导出数据库语句举例:

exp scpssts/scpssts123@dicpsi file = D:\ora\scpssts.dmp owner = scpssts log=D:\ora\scpssts.log

更改后重新启动jboss编译成功。

热门排行

今日推荐

热门手游