How to Create a Text File for MySQL

You can create a text file for MySQL by using a text editor or software program. Text files can send commands or load data to MySQL. Each text file must match the format MySQL is expecting. For example, if MySQL needs to execute the SQL statement in the text file, then the text file must contain a valid MySQL statement. If you want to load data into a MySQL table from a text file, then each record must match the database format of the MySQL table.

Instructions

    • 1

      Click "Start > All Programs > Accessories > Notepad."

    • 2

      Type the SQL commands in the text file. For example, if you want to create a table that will store all of the U.S. presidents and their election dates, type "CREATE TABLE president (last_name VARCHAR (15) NOT NULL, first_name VARCHAR (15) NOT NULL, election_date DATE NULL);" (no quotes).

    • 3

      Click "File > Save" and save the file with the extension ".sql." For example, a good file name for the SQL commands in the text file in Step 2 is "create_president.sql."

    • 4

      To create a text file with data for loading, open Notepad. "Type INSERT INTO president VALUES ('Hoover','Herbert','1928-11-04');" (no quotes).

    • 5

      Click "File > Save" to save the text file as "insert_president.sql."

Related Searches:

References

Resources

Comments

You May Also Like

Related Ads

Featured