How to Import SQL With a Command Line

Save

Microsoft SQL Server bulk copy command (bcp) gives you the ability to insert large volume of records into a database directly from the command line. It generates the format files that contain information about the corresponding SQL Server table. The format file is required to import data to a user installation of SQL Server. By using bcp format files you eliminate the need to reformat the data to the requirements of SQL Server before the data import operation.

Microsoft SQL Server

  • Click "Start" in Windows and then click "Run." Enter "cmd" in the "Open" field and click "OK" to open the command line window.

  • Enter the following command to import records into the "products" table of the inventory "electronics" database:

    bcp inventory.dbo.products in C:\electronics\inventory.txt

  • Press the "Enter" key to import data from the "inventory.products" file into the "electronics" database.

Oracle Database 10g

  • Click "Start" and then click "Oracle Database 10g." Click "Run SQL Command Line" on the menu. Type in "sqlplus" and press the "Enter" key.

  • Type in the following SQL*Loader command at the "SQL>" prompt:

    sqlldr EXTERNAL_TABLE DATA=orders.dat CONTROL=products.ctl LOG=products.log

  • Press the "Enter' key to execute the import of the "orders.dat" file data into the "products" database table.

IBM DB2 DBMS

  • Click "Start" in Windows and then click "Run." Enter "db2cmd" in the "Open" field and click "OK" to open command line window.

  • Enter the following command at the prompt to import information from mycomm.ixf to the "Email" table:

    db2 IMPORT FROM mycomm.ixf OF ixf messages msg.txt INSERT INTO Email

  • Press the "Enter' key to execute the import of messages from "mycomm.ixf" file to the "Email" database table.

MySQL DBMS

  • Click "Start" in Windows and then click "Run." Enter "cmd" in the "Open" field and click "OK" to open command line window. Type "sql" at the prompt and press the "Enter" key.

  • Type in the following MySQL command at the "SQL>" prompt to import data from the "employees.txt" file into the "staff" database:

    mysqlimport staff emloyees.txt

  • Press the "Enter" key to execute the import of data into the "staff" MySQL database.

References

  • Photo Credit Jupiterimages/Photos.com/Getty Images
Promoted By Zergnet

Comments

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!