The method of importing txt text data into mysql
This article mainly introduces the method of importing txt text data into mysql, which is very detailed and has a certain reference value. Interested friends must finish reading it!
Mysql imports txt text data: first, create a database and table; then create a table and write the data into a [pet.txt] text; finally, use the command to import the database.
Methods for mysql to import txt text data:
First create the database and tables:
Mysql > create database menagrie
Then create the table:
Mysql > CREATE TABLE pet (name VARCHAR (20), owner VARCHAR (20), species VARCHAR (20), sex CHAR (1), birth DATE, death DATE)
Then write the following data to an pet.txt text:
Fluffy Harold cat f 1993-02-04\ NClaws Gwen cat m 1994-03-17\ NBuffy Harold dog f 1989-05-13\ NFang Benny dog m 1990-08-27\ NBowser Diane dog m 1979-08-31 1995-07-29Chirpy Gwen bird f 1998-09-11\ NWhistler Gwen bird\ N 1997-12-09\ NSlim Benny snake m 1996-04-29\ N
Use the following command to import the database:
Mysql > LOAD DATA LOCAL INFILE'/ path/pet.txt' INTO TABLE pet
After completion, you can get the results:
The above is all the contents of mysql's method of importing txt text data, thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!