I'm new to SQL and using it for something at work.
I have the following table I made:
CREATE TABLE PC_Contacts
(
POC VARCHAR(255) PRIMARY KEY NOT NULL,
Phone_1 VARCHAR(255),
Phone_2 VARCHAR(255)
);
I import some data from a CSV into the table using the following command in powershell: cmd /c 'mysql -u root -p network < CSVImport.sql'. This is what is contained within the CSVImport file:
USE Network
LOAD DATA INFILE 'C:\\ProgramData\\MySQL\\MySQL Server 5.7\\Uploads\\PC_Contacts.csv'
INTO Table PC_Contacts
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
After populating the table, something I noticed is when the last column (Phone_2) doesn't have a phone number populated, instead of inputting a NULL value, it is blank. In addition, several characters on the POC column are cut off whenever a phone number is omitted. So I input xxx-xxx-xxxx into the columns, repopulated it, and everything looked clean. How can I make it so I don't have to do this and the table can just populate itself with NULL values?
+------------------+--------------+--------------
| POC | Phone_1 | Phone_2
+------------------+--------------+--------------
|April Wilson| 123-456-7890 | xxx-xxx-xxxx
|Anton Watson | 234-567-8901| 567-890-1234
|Ashley Walker | 345-678-9012 | 456-789-0123
Names and phone have been altered, of course . If I were to take xxx-xxx-xxxx out though, you would see in the POC column something like 'lson' instead of the full name. Any thoughts?