zoukankan      html  css  js  c++  java
  • 从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

    更正为

  • 相关阅读:
    JavaScript中严格模式"use strict";需注意的几个雷区:
    React 学习,需要注意几点
    安装了VS2012 还有Update4 我的Silverlight5安装完后 我的Silverlight4项目打不开
    SilverLight抛出 System.InvalidOperationException: 超出了2083 的最大URI
    Dictionary集合运用
    配置OpenCV开发环境心得
    调用第三方库出现的问题
    7-19 答疑课小结
    工欲善其事必先利其器(篇一)
    VMware Ubuntu Kaldi
  • 原文地址:https://www.cnblogs.com/lurenjia1994/p/9709197.html
Copyright © 2011-2022 走看看