Search⌘ K
AI Features

Exercise: Data Import and Export

Explore hands-on data import and export tasks using CSV, XML, JSON, and SQL dumps to manage MySQL databases. Learn to handle NULL values, format data exports, and optimize backup processes for database reliability.

We will now proceed with the practical work.

Question 1

Given the structure of the Customers table below:

Field

Type

CustomerID

int

CustomerName

varchar(50)

Email

varchar(50)

Phone

varchar(15)

Address

varchar(100)

LastLogin

date

CreatedAt

timestamp

CustomerTier

enum('New','Regular','VIP')

ReferralID

int

LoyaltyPoints

int

LastPurchaseDate

date

IsChurnRisk

boolean

Where CustomerID is the primary key and ReferralID is self-referencing to CustomerID. The table contains information about customers.

Consider a CSV file special_customers.csv where NULL for Phone is represented by N/A and for Address by an empty field.

CustomerName,Email,Phone,Address,CustomerTier
"Test User One","test1@example.com","N/A","",New
"Test User Two","test2@example.com","555-9900","77 Test Drv",Regular

Import this data into the Customers table, ensuring ‘N/A’ for phone becomes NULL ...