Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3693160
  • 博文数量: 715
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(715)

文章存档

2023年(75)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

分类: Oracle

2023-07-20 15:22:24

数据导入时大量宽度不足


  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宽度
阅读(285) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~