MySql使用插入语句插入txt文件
我想知道通过 txt 文件插入数据的最佳格式是什么。
我输入了几个由制表符索引分隔的值。而且效果很好。但我希望我的文件看起来干净整洁!我希望它们是可读的,因为几个值将简单地创建一个无尽的 lomg 行。 所以我想要一个txt文件,其中包括insert into语句和可读数据,例如彼此下面的每个字段。 。用逗号,nrackets 例如(见下文)
我做错了什么,因为我无法读取这些数据字段。如前所述,我可以在文件中不使用插入语句的情况下读取制表符分隔的值(我将其放在命令行中),但我想将它们也放入 txt 文件中!
感谢您对此事的任何提示
INSERT INTO COUPON(
id,
title,
product_description,
product_name,
current_price,
original_price,
business_name,
business_description,
fine_print,
start_date,
end_date,
start_time,
end_time,
min_coupons,
max_coupons,
mem_id,
deal_status)
VALUES(
'4',
'tile',
'product description',
'product name here',
'15.000',
'30.000',
'name',
'example',
'fine print!',
'2011-03-24',
'2011-03-25',
'12:00:00',
'12:00:00',
'10',
'20',
'1936',
'N'),
( . . .), ( . . .), . . . .
I am wondering what the best format is to insert data via a txt file.
I have entered few values separated by a tab index. And it works fine. But i would liek my file to look neat and tidy !! I would like them to be readable, as several value s will simple create a endless lomg line.
So I want a txt file, that includes the insert into statement and readable data such as each field underneath each other . . with commas, nrackets e.g. (see below)
What am I doing wrong, as I am not able to read in those data fields. As said, I am able to read tab separated values without the insert statement within the file ( I put that in the command line) But I would like to put these also into the txt file !
Thanks for any hints in this matter
INSERT INTO COUPON(
id,
title,
product_description,
product_name,
current_price,
original_price,
business_name,
business_description,
fine_print,
start_date,
end_date,
start_time,
end_time,
min_coupons,
max_coupons,
mem_id,
deal_status)
VALUES(
'4',
'tile',
'product description',
'product name here',
'15.000',
'30.000',
'name',
'example',
'fine print!',
'2011-03-24',
'2011-03-25',
'12:00:00',
'12:00:00',
'10',
'20',
'1936',
'N'),
( . . .), ( . . .), . . . .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 phpmyadmin、Navicat 等工具,您可以以 CSV(逗号分隔值)格式导出+导入。如果您想查看可读的“按列排列”的文件,请使用 MS-excel 打开它。
这也可以从 CMD 导出 csv:
来源: http:// forums.mysql.com/read.php?79,11324,204768#msg-204768
有关命令的信息:http://www.debianadmin。 com/export-mysql-database-into-a-csv-file.html
using tools like phpmyadmin, Navicat you can export+import in CSV (comma separated value) format. if you wanna see the file readable "arranged in columns" open it with MS-excel.
also this can do csv export from CMD:
source: http://forums.mysql.com/read.php?79,11324,204768#msg-204768
info about the command: http://www.debianadmin.com/export-mysql-database-into-a-csv-file.html