mysql導入txt文本數(shù)據(jù)的方法:首先創(chuàng)建數(shù)據(jù)庫和表;然后創(chuàng)建表,將數(shù)據(jù)寫入一個【pet.txt】文本中;最后使用命令實現(xiàn)導入數(shù)據(jù)庫即可。
mysql導入txt文本數(shù)據(jù)的方法:
首先創(chuàng)建數(shù)據(jù)庫和表:
mysql> create database menagrie;然后創(chuàng)建表:
mysql> create table pet (name varchar(20), owner varchar(20), species varchar(20), sex char(1), birth date, death date);然后將以下數(shù)據(jù)寫入一個pet.txt文本中:
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
使用以下命令實現(xiàn)導入數(shù)據(jù)庫:
mysql> load data local infile '/path/pet.txt' into table pet;完成后即可得到結果:
相關學習推薦:mysql學習