...

/

Exercise: Data Import and Export

Exercise: Data Import and Export

Practice and test your understanding of data import and export.

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 and ...