JIYIK CN >

Current Location:Home > Learning > DATABASE > MySQL >

Creating a table from CSV in MySQL

Author:JIYIK Last Updated:2025/04/25 Views:

In this article, we aim to understand how to create a table from CSV in MySQL database.

Businesses and organizations must quickly generate tables from large amounts of data. These organizations typically have large CSV files with large amounts of data evenly distributed across multiple fields in the file to accomplish this task.

Sometimes, it becomes necessary for an analyst to create a table directly from such CSV files. In this tutorial, let us understand this concept.

Let's collect some data in a CSV file to understand this better.

We can name this file as dummy_data. See our CSV file as shown below.

mysql create trable from csv 1

Now that we have our data set up in a CSV file, let's learn how to convert this data into a table in MySQL.

Creating a table from CSV in MySQL using MySQL Workbench

TablesWe can do this in MySQL Workbench by right clicking on the tab for our database . It will show us 表数据导入向导the tabs.

As shown in the figure below.

mysql create trable from csv 2

After clicking on the tab, we can select the path of the CSV file and click 下一步as shown below.

mysql create trable from csv 3

We keep clicking Next until our task is executed. After successfully running all the tabs, you can see the created tables in the left tab of MySQL Workbench.

The name of the newly created table will be the same as the file name given previously.

Alternatively, we can look up data from the table to ensure that the table has been created. We can do this using the query below.

SELECT * from dummy_data;

The query loops through our entire table and fetches the values. The output of the query is shown below.

Client 	Job Name						Fees Paid		Taxes Paid     Total Billed 	Your Earnings
b	pay per project						-7.6			-0.38			38				30.02
A	How-To Style Article Writers Needed	-26.1			-1.31			130.5			103.09
C 	Consultancy	Technical writers for 	-19.8			-0.99			99				78.21
d	Developing a Machine Learning model	-5				-0.25			25				19.75

ASWe use aliases with keywords in MySQL Jobsto increase the readability of programs in output blocks.

So, with the help of queries and methods, we can create a new table from CSV entries efficiently and quickly in MySQL.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

How to select from multiple tables in MySQL

Publish Date:2025/04/25 Views:57 Category:MySQL

This article explains how to use MySQL to query from multiple tables in one script SELECT . Let's demonstrate a situation: SELECT name , price, details, type , FROM food, food_order WHERE breakfast.id = 'breakfast_id' Now, let's imagine FRO

Get column names in MySQL

Publish Date:2025/04/25 Views:109 Category:MySQL

In this article, we aim to explore how to get the column names of a specific table in MySQL database. Often, when working with data in MySQL, we tend to forget the column names of a particular table in the database and the data types of dif

Get the version in MySQL

Publish Date:2025/04/24 Views:170 Category:MySQL

In this article, we will learn how to get the current version of MySQL on Windows systems. It is necessary for businesses to maintain versions of different tools and software used to run their business in order to keep systems compatible. T

Full Join in MySQL

Publish Date:2025/04/24 Views:71 Category:MySQL

This article aims to explore how to perform a full join or full outer join in MySQL. Full outer join is used to merge or combine the entire data from two separate tables. For example, suppose we have two tables named student_id and student_

Grouping by month in MySQL

Publish Date:2025/04/24 Views:166 Category:MySQL

In this article, we will learn how to group values ​​by month in MySQL database. Businesses and organizations have to find user or customer data based on purchase or usage trends over a few months. If a particular business achieves its

Enabling the slow query log in MySQL

Publish Date:2025/04/24 Views:177 Category:MySQL

Today, we will enable MySQL in MySQL using MySQL shell on Windows and Ubuntu 20.04 slow_query_log . For this tutorial, we are using MySQL version 8.0 and Ubuntu 20.04. MySQL slow_query_log MySQL slow_query_log contains SQL statements that t

Update multiple tables in MySQL with one query

Publish Date:2025/04/24 Views:66 Category:MySQL

In some cases, users want to update logically related tables at the same time. These logically related tables are linked to each other through some attributes. Advantages of updating multiple tables in one MySQL query Similar attributes in

Checking MySQL version in macOS

Publish Date:2025/04/24 Views:60 Category:MySQL

In this article, we aim to explore how to check the current version of MySQL on macOS. Checking MySQL version in macOS When trying to figure out the version, you must follow these steps. Each time a person logs into the MySQL server, the ve

Common table expressions in MySQL

Publish Date:2025/04/24 Views:169 Category:MySQL

This article aims to understand how to use common table expressions in MySQL. Most data analysts need to store the results of different queries in order to merge them with a separate query. With the help of common tables, expressions can ma

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial