Home > Database > Mysql Tutorial > body text

How to import txt text data in mysql

coldplay.xixi
Release: 2020-08-25 09:32:55
Original
5670 people have browsed it

Mysql method of importing txt text data: first create the database and table; then create the table and write the data into a [pet.txt] text; finally use the command to import the database.

How to import txt text data in mysql

Mysql method of importing txt text data:

First create the database and table:

mysql> create database menagrie;
Copy after login

Then create the table:

 mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
        species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
Copy after login

Then write the following data into a pet.txt text:

Fluffy Harold cat f 1993-02-04 \N
Claws Gwen cat m 1994-03-17 \N
Buffy Harold dog f 1989-05-13 \N
Fang Benny dog m 1990-08-27 \N
Bowser Diane dog m 1979-08-31 1995-07-29
Chirpy Gwen bird f 1998-09-11 \N
Whistler Gwen bird \N 1997-12-09 \N
Slim Benny snake m 1996-04-29 \N
Copy after login

Use the following command to import the database:

mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;
Copy after login

You will get the result after completion:

How to import txt text data in mysql

Related learning recommendations: mysql learning

The above is the detailed content of How to import txt text data in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template