![]() Let us first truncate the developers’ table using the following statement – Just in case, if they duplicate while importing then an error will be given. However, note that we can add the data by importing the CSV in the table that already contains the records in the same manner and it does not have any effects on the existing records. Firstly, we will truncate the table in order to make the concepts clear and understanding better. Let us try importing this content in the workbench.Consider the following CSV file that has the same name as earlier but different contents than previous with developer names Mahesh, Suresh, Ganesh, and Saheeh – ![]() Let us look at how we can import the contents of the CSV file into the table in workbench with the help of an example. Note that in MySQL using the command-line, we can import the contents of the CSV file into the table contents by using the LOAD DATA INFILE statement. There is also the provision to import the contents of the CSV file into the table contents in Workbench by simply clicking on the import button and then specifying the path and name of the file. Importing data from CSV to Table Contents in Workbench ![]() To confirm whether the imported data of the CSV got inserted in the table properly, let us retrieve the contents of the developers’ table and compare them with the CSV file we had earlier using the following query statement – We can see that four rows were affected and all the four rows got inserted successfully without any warning or error. LOAD DATA INFILE '/var/lib/mysql-files/R_developers_cmd.csv' To import resultset from CSV file we will make the use of LOAD DATA INFILE clause as shown below – ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1 `developer_id` int(11) NOT NULL AUTO_INCREMENT, Let us create the developer’s named table in our database educba that will hold all the above data – ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |