Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can i successfully import a csv file to a table in my sql. For example my csv file is FleetMainLtenanceRecords.csv my table is PartsMaintenance

How can i successfully import a csv file to a table in my sql.

For example my csv file is FleetMainLtenanceRecords.csv

my table is PartsMaintenance

When putting this code in:

LOAD DATA INFILE 'c:/FleetMaintenanceRecords.csv'

INTO TABLE PartsMaintenance FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '/n'

IGNORE 1 ROWS;

I receive this error code:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that c orresponds to your MySQL server version for the right syntax to use near 'LOCAL ' c:/FleetMainLtenanceRecords.csv' INTO TABLE PartsMaintenance

When trying this code instead:

LOAD DATA LOCAL INFILE 'c:/FleetMainLtenanceRecords.csv' -> INTO TABLE PartsMaintenance -> FIELDS TERMINATED BY ',' -> ENCLOSED BY '"' -> LINES TERMINATED BY ' ' -> IGNORE 1 ROWS;

I receive this error code: ERROR 1148 (42000): The used command is not allowed with this MySQL version

and finally

LOAD DATA INFILE 'c:/FleetMaintenanceRecords.csv' -> INTO TABLE PartsMaintenance -> FIELDS TERMINATED BY ',' -> ENCLOSED BY '"' -> LINES TERMINATED BY ' ' -> IGNORE 1 ROWS;

this presents the error code : ERROR 13 (HY000): Can't get stat of '/var/lib/mysql/c:/FleetMaintenanceRecords.c sv' (Errcode: 2)

Please HELP!

csv file sample:

Vehicle ID,State,Repair ,Reason,YEAR ,Make,Body Type 0000015241383936,AL,Battery replacment,Dead battery,2016,RAM ,"1500 4WD Quad Cab 140.5"" SLT" 0000015241383936,AL,Dent Repair Left Fender,Collision,2016,RAM ,"1500 4WD Quad Cab 140.5"" SLT" 0000060965535744,AL,Battery replacment,Dead battery,2016,RAM ,"1500 4WD Quad Cab 140.5"" SLT" 0000060965535744,AL,Tire repair,Flat- reparable,2016,RAM ,"1500 4WD Quad Cab 140.5"" SLT" 0000060965535744,AL,Tire replacement,Flat- hole not reparable,2016,RAM ,"1500 4WD Quad Cab 140.5"" SLT" 0000137172455424,AL,Battery replacment,Dead battery,2017,Chevrolet Silverado ,"1500 4WD Double Cab 143.5"" LT w/1LT" 0000137172455424,AL,Windshield replacement,Crack,2017,Chevrolet Silverado ,"1500 4WD Double Cab 143.5"" LT w/1LT" 0000243862142976,AL,Dent Repair Rear,Collision,2019,RAM ,"1500 Classic SLT 4X2 Crew Cab 6'4"" Box" 0000381034598400,AR,Windshield replacement,Crack,2016,RAM ,"1500 4WD Quad Cab 140.5"" SLT"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions