Skip to content
Advertisement

How do I load values in txt file to mysql table colum

I have value like this stored in value.txt file

I have created table in the below way

I am unable to find a way to insert the txt file details in payload columnn of table.

I saw load option is there but it is more of entire table oriented. I want the txt files value to be in specific column.

Any Help is widely appreciated

Advertisement

Answer

Use LOAD_FILE() (pay attention to needed account privileges and server settings values).

The function returns complete file content as binary string. For to convert it to text use CAST() function.

If a file contains more than one row then load it in CTE or into temptable then parse to separate values and save.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement