• 从word得到表格数据插入数据库(6位行业代码)


    复制表格到excel

    点击表格左上角选中全部表格,然后crtl+c,再贴到excel中

    可以发现,大类代码,单元格往下走,碰到下一个有值的之前,都是上一个的范围

     

    填充空白单元格

    1.选中前四列,然后ctrl+g定位空白表格

    2.按住ctrl,点击有值的下一个单元格,写入等于上一个单元格的公式,然后ctrl+enter

     写插入数据库语句

    最好写成insert into values(1, 2, 3), (1, 2, 3);

    但Oracle不支持

     最好双击写公式的单元格,然后复制,得到sql如下

    数据太多直接崩了

    oracle命令行导入sql文件

    1.建表,字段值远大于实际值,防止空格这些引起超长度

    -- Create table
    create table INDUSTRY
    (
      code1         VARCHAR2(20),
      code2         VARCHAR2(20),
      code3         VARCHAR2(20),
      code4         VARCHAR2(20),
      code5         VARCHAR2(20),
      industry_name VARCHAR2(500)
    )
    tablespace SYSTEM
      pctfree 10
      pctused 40
      initrans 1
      maxtrans 255
      storage
      (
        initial 64K
        next 1M
        minextents 1
        maxextents unlimited
      );
    -- Add comments to the columns 
    comment on column INDUSTRY.code1
      is '1位代码';
    comment on column INDUSTRY.code2
      is '2位代码';
    comment on column INDUSTRY.code3
      is '3位代码';
    comment on column INDUSTRY.code4
      is '4位代码';
    comment on column INDUSTRY.code5
      is '6位代码';
    comment on column INDUSTRY.industry_name
      is '行业名称';
    View Code

    2.打开cmd窗口,输入命令如下:sqlplus username/password@ip:port/实例名

    3.@C:UsersuserDownloads6位行业代码插入2.sql(你的文件的位置)

     

    去除空格

    update industry set 
    code1 = trim(code1),
    code2 = trim(code2),
    code3 = trim(code3),
    code4 = trim(code4),
    code5 = trim(code5),
    industry_name = trim(industry_name)

     

    处理不合格数据

    可发现,code2,code3,code4应该为code5的前几位

    通过sql找出不合格的数据

    select * from industry
    where length(code5)=6
    and (
    substr(code5,0,2)!=code2 
    or substr(code5,0,3)!=code3
    or substr(code5,0,4)!=code4
    )

    执行更新sql

    update industry set
    code2 = substr(code5,0,2),
    code3 = substr(code5,0,3),
    code4 = substr(code5,0,4)
    where length(code5)=6
    and (
    substr(code5,0,2)!=code2 
    or substr(code5,0,3)!=code3
    or substr(code5,0,4)!=code4
    )

    不合格数据2

    select * from industry
    where length(code4)=4
    and (
    substr(code4,0,2)!=code2 
    or substr(code4,0,3)!=code3
    )

    更正sql

    update industry set
    code2 = substr(code4,0,2),
    code3 = substr(code4,0,3)
    where length(code4)=4
    and (
    substr(code4,0,2)!=code2 
    or substr(code4,0,3)!=code3
    )

    处理填充过来的标题跟0

    select * from industry 
    where length(code2)!=2
    or length(code3)!=3
    or length(code4)!=4
    or length(code1)!=1 
    for update

    更正为

  • 相关阅读:
    一起谈.NET技术,Silverlight中二维变换详解 狼人:
    一起谈.NET技术,通过16道练习学习Linq和Lambda 狼人:
    一起谈.NET技术,技巧:使用可扩展对象模式扩展HttpApplication 狼人:
    一起谈.NET技术,ASP.NET的运行原理与运行机制 狼人:
    一起谈.NET技术,.NET远程处理框架详解 狼人:
    一起谈.NET技术,从原理来看Silverlight 4的架构 狼人:
    一起谈.NET技术,ASP.NET MVC中对Model进行分步验证的解决方法 狼人:
    一起谈.NET技术,解决编程中序列化问题 狼人:
    一起谈.NET技术,asp.net控件开发基础(2) 狼人:
    一起谈.NET技术,asp.net控件开发基础(1) 狼人:
  • 原文地址:https://www.cnblogs.com/lurenjia1994/p/9709197.html
Copyright © 2020-2023  润新知