import text file into mysql workbench?(将文本文件导入mysql工作台?)
问题描述
我想知道如何将文本文件导入 MySQL 工作台?
I was wondering how to import text file into MySQL workbench?
我有一个由 | 分隔的文本文件,第一行是表格,
I have a text file delimited by | and the first row are the tables,
FEATURE_ID|FEATURE_NAME|FEATURE_CLASS
然后是后面的数据信息
1388627|Etena|Populated Place
将此 .txt 文件导入 MySQL 工作台的最佳方法是什么?
What is the best way to import this .txt file into MySQL workbench?
谢谢1
推荐答案
目前还不清楚您到底要实现什么,但是如果您想将带分隔符的文本文件导入到 db 中,则可以使用 LOAD DATA INFILE 像这样:
It's not clear what exactly you intend to achieve, but if you want to import delimited text file into db then you can use LOAD DATA INFILE like this:
LOAD DATA INFILE '/path/file.txt'
INTO TABLE tablename
FIELDS TERMINATED BY '|'
LINES TERMINATED BY '
'
IGNORE 1 LINES;
更新:
首先,您需要像这样创建表(如果还没有完成):
First of cause you need to create the table (if it's not done yet) like this:
CREATE TABLE `tablename` (
`FEATURE_ID` int(11) unsigned NOT NULL,
`FEATURE_NAME` varchar(512) DEFAULT NULL,
`FEATURE_CLASS` varchar(512) DEFAULT NULL,
PRIMARY KEY (`FEATURE_ID`)
)
您可能需要调整该表的数据类型、长度和约束.例如,您可能不需要那个桌子上的 PK.
You might need to adjust data types, lengths, and constraints on that table. For example you might not need a PK on that table.
这篇关于将文本文件导入mysql工作台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将文本文件导入mysql工作台?
基础教程推荐
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 在多列上分布任意行 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
