大量宽度不够问题,简单加工

330阅读 0评论2023-07-20 brjl
分类:Oracle

数据导入时大量宽度不足


  1. ORA-02374: conversion error loading table "SCOTT"."PERSON"
  2. ORA-12899: value too large for column OCCUPATION (actual: 60, maximum: 50)
  3. ORA-02374: conversion error loading table "SCOTT"."PERSON"
  4. ORA-12899: value too large for column EMPLOYEE (actual: 75, maximum: 50)
  5. ORA-02374: conversion error loading table "SCOTT"."PERSON"
  6. ORA-12899: value too large for column EMPLOYEE (actual: 60, maximum: 50)
  7. ORA-02374: conversion error loading table "SCOTT"."PERSON"
  8. ORA-12899: value too large for column EMPLOYEE (actual: 57, maximum: 50)
  9. ORA-02374: conversion error loading table "SCOTT"."PERSON"
  10. ORA-12899: value too large for column EMPLOYEE (actual: 60, maximum: 50)
  11. ORA-02374: conversion error loading table "SCOTT"."PERSON"
  12. ORA-12899: value too large for column EMPLOYEE (actual: 53, maximum: 50)
  13. ORA-02374: conversion error loading table "SCOTT"."PERSON"
  14. ORA-12899: value too large for column DUTY (actual: 74, maximum: 50)
  15. ORA-02374: conversion error loading table "SCOTT"."PERSON"
  16. ORA-12899: value too large for column EMPLOYEE (actual: 60, maximum: 50)
  17. ORA-02374: conversion error loading table "SCOTT"."ADDRESS"
  18. ORA-12899: value too large for column NAME (actual: 70, maximum: 50)
  19. ORA-02374: conversion error loading table "SCOTT"."ADDRESS"
  20. ORA-12899: value too large for column NAME (actual: 81, maximum: 50)
  21. ORA-02374: conversion error loading table "SCOTT"."ADDRESS"
  22. ORA-12899: value too large for column PHONENUMBER (actual: 18, maximum: 15)
  23. ORA-02374: conversion error loading table "SCOTT"."USER"
  24. ORA-12899: value too large for column REMARK (actual: 180, maximum: 100)
可以简单加工一下

  1. #!/bin/sh

  2. i=1
  3. width=0
  4. fn=/tmp/out.log
  5. echo > $fn
  6. cat t.txt | while read line
  7. do
  8.   i=$(($i+1))
  9.   errCode='ORA-02374'
  10. if [[ $line =~ $errCode ]]
  11. then
  12.     table=`echo $line |awk -F"conversion error loading table" '{print $2}'`
  13. fi

  14. largeCode='ORA-12899'
  15. if [[ $line =~ $largeCode ]]
  16. then
  17.     column=`echo $line |awk -F"value too large for column" '{print $2}'|awk -F"(" '{print $1}'`
  18.     width=`echo $line |awk -F"actual:" '{print $2}'|awk -F"," '{print $1}'`
  19. fi

  20. # alter table
  21. if [[ $line =~ $largeCode ]] && [[ $width -gt 0 ]]
  22. then
  23. echo 'alter table ' $table ' modify ' $column ' varchar2(' $width ');' >> $fn
  24. width=0
  25. fi

  26. done

  27. sort $fn|uniq

  28. 求max值
  29. # awk -F"[()]" '{print $2}'|awk 'BEGIN{ max = 0} {if ($1 > max) max = $1; fi} END{print max}'
还不完美,没有能够实现只显示max宽度
上一篇:较为靠谱的oracle表空间使用率
下一篇:dm_tskwrk_thd cpu 繁忙