当前位置:网站首页>Possible problems in inserting Excel data into MySQL database
Possible problems in inserting Excel data into MySQL database
2022-07-19 12:49:00 【liliane】
1. take excel Data preservation txt file , Or manually copy to txt, By default, a tab Column interval .
2. stay mysql Create tables in the database :create table table_name ...
3. Use mysql Of load Command to import local data :
load data local infile"path" into table table_name fields terminated by '\t'; //path Is the file path ,table_name Is the name of the watch
perhaps
load data local infile"path" into table table_name("field1","field2"...); //field Is the corresponding field name
Be careful , If the inserted encoding format is incorrect , It may appear that the record is null perhaps “?” The situation of , here , Need to put txt Change the code to utf-8( Use editplus, Or notepad , adopt “ Save as ”, Set encoding ).
If you use the method of primary key self increment (auto_increment), When you import data incorrectly for the first time , Delete (delete), Re import , Will find key The value of is no longer from 1 Start ( The previous serial number has been used ). If necessary , Before re importing , adopt “alter table table_name auto_increment=1” command , To modify the auto_increment The initial value of the .
Besides , Import data , There may be format problems , If there are spaces at the beginning and end , You can use trim function :
update table_name set field = trim(field);
You can even choose to remove the left or right space ,ltrim,rtrim;
If you want to remove all spaces , You can use replace function :
update table_name set field = replace(field, ' ', '');
边栏推荐
- 运维小白成长记—架构第6周
- ATT&CK实战系列——红队实战(—)
- LeetCode_ Prefix and_ Medium_ 523. Continuous subarrays and
- The active and standby cache of redis cluster is full, causing frequent active and standby switchover
- July training (day 17) - breadth first search
- Preparation Notes: Matplotlib learning notes a
- Thoughts on ahe investment
- 超声波传感器(CH101&ch201) - Ⅱ
- Redis集群主备缓存区满了导致主备频繁倒换
- 国产API工具哪家强?原来是它…
猜你喜欢

Detailed explanation of RAID disk array, raid classification, advantages and disadvantages

Notes on the fifth day

Mycat2 builds MySQL master-slave separation

Database daily question --- day 25: bank account summary II

稳超胜算,历9弥新 | 2022金仓创新产品发布会顺利召开

虞美人·寄公度

超声波传感器(CH101&ch201) - Ⅱ

OpenCV:06形态学

Acwing4405. 统计子矩阵

国产API工具哪家强?原来是它…
随机推荐
go web
C # from introduction to mastery Part II: C # basic grammar
Useeffect summary
Acwing4405. Statistical submatrix
go web
MYCAT divides the database and table according to the hash value of the string range
S32K148_ Can drive (bare metal development)
2022 global developer salary exposure: China ranks 19th, with an average annual salary of $23790
Growth of operation and maintenance Xiaobai - week 6 of Architecture
Committer identity unknown *** Please tell me who you are...
Relationship and difference between wav and PCM
Harmonyos quick start: Hello World
mycat 根据字符串范围hash值分库分表
Brief analysis of circuit fault
水调歌头·明月几时有
How can MySQL delete data tables and associated data tables
Deep learning parameter initialization (II) Kaiming initialization with code
Array de duplication array sorting maximum sum class array conversion filter array
Structure memory alignment, bit segment, union
深度学习参数初始化(二)Kaiming初始化 含代码