ORA-00972: 标识符过长解决办法

时间:2025-03-23 18:40:10

: ORA-00972: 标识符过长

    • ORA-00972: 标识符过长博客申明
    • ORA-00972: 标识符过长代码提要
    • ORA-00972: 标识符过长异常原因

ORA-00972: 标识符过长博客申明

每个人的代码差异不同,不代表所有问题错误都出自于此,我只分享我出现问题的场景及原因

以下sql使用的连接方式是jdbctemplate

ORA-00972: 标识符过长代码提要

异常如下

PreparedStatementCallback; bad SQL grammar 
[insert into special_require_hs t 
(t.lg_mcsr_id,t.lg_updated,t.lg_updated_user,t.lg_type,t.mcsr_id,t.vid,t.updated,
t.updated_user,t.customer,t.warehouse,t.partno,t.special_require,t.type,t.remark,
t.flag) 
values
(posse.cre_duct_special_require_hs_seq,sysdate,?,?,?,?,?,?,?,?,?,?,?,?,?)]; 
nested exception is java.sql.SQLException: ORA-00972: 标识符过长

后台代码

public void addMSpecialRequireHs(SpecialRequire item) {
		String sql = "insert into special_require_hs t "
				+ "(t.lg_mcsr_id,t.lg_updated,t.lg_updated_user,t.lg_type,"
				+ "t.mcsr_id,,,t.updated_user,,,,t.special_require,,,) "
				+ "values(posse.cre_duct_special_require_hs_seq,sysdate,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		commonManager.save(new Sql("dataSourceMeass", sql, new String[] {"lgUpdatedUser","lgType","mcsrId","vid","updated","updatedUser","customer","warehouse","partno","specialRequire","type","remark","flag"}), item);
		}

ORA-00972: 标识符过长异常原因

错误原因:
插入数据时序列的问题 posse.cre_duct_special_require_hs_seq 序列名太长所致,所以插入序列时,提前验证你的序列是否创建并能够正常获取序列