In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the method of importing mysql into txt files. I hope you will gain a lot after reading this article. Let's discuss it together.
First, prepare the data and establish the test table
1. Prepare the txt text document to be imported, and the path is: c:/data.txt.
Each item is separated by the Tab key, or / N if the field is NULL.
2. Create a new database and a table. The fields designed in the table need to correspond to the number of imported text document columns.
Example: create a table that represents student information for the test, with fields such as id, name, age, city, and salary. Id and name cannot be empty.
Create table person (id int not null auto_increment,name varchar (40) not null,city varchar (20), salary int,primary key (id)) engine=innodb charset=gb2312
Create a table with screenshots as follows:
Second, import data
Enter the command to import:
Load data local infile "c:/data.txt" into table person (name,age,city,salary)
The screenshot of the imported data is as follows:
Where local represents local. After execution, you can see that the NULL data is also imported correctly.
III. Export data
Now export the table as a text file: c:/data_out.txt.
Select name,age,city,salary into outfile "c:/data_out.txt" lines terminated by "/ rzone" from person
The screenshot of the exported data is as follows:
Where "lines terminated by" indicates that each line (that is, each record) is separated by / rzone, which is the newline character of the window series. The exported data_out.txt is exactly the same as the data.txt.
After reading this article, I believe you have a certain understanding of the method of importing txt files into mysql. Want to know more about it. Welcome to follow the industry information channel. Thank you for your reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.