Importing data into a database from a delimited file is perhaps one of the most common tasks that one might have to perform. SQL server gives us an import utility which supports various data sources and has an intutive interface as well,however there is another way which can be utilized to quickly get the job done, its called BULK INSERT BULK INSERT is a SQL command which can be typed in management console,takes various parameters to control the import and is very simple to use.
This is going to be a short article which will illustrate importing and exporting a table from or to a csv file using PostgreSQL COPY command. Importing a table from CSV Assuming you already have a table in place with the right columns, the command is as follows COPY FROM ‘/path/to/csv/SourceCSVFile.csv’ DELIMITERS ‘,’ CSV; Exporting a CSV from a table. COPY TO ‘/path/to/csv/TargetCSVFile’ DELIMITERS ‘,’ CSV; Its important to mention here that generally if your data is in unicode or need strict Encoding, then Always set client_encoding before running any of the above mentioned commands.
I absolutely love SQLite, be it windows, linux or mac, this light weight database never stops to amaze me. Few days ago I wanted to import a chunk of CSV data, which was 4 GB in size into a table in SQLite. I generally use Firefox ’s sqlite-manager plug-in for usual tasks with SQLite database ,hence decided to use the import interface . I have had a very good experience with this GUI tool and it has rarely failed me, but this time I was disappointed.