Import data from external sources
PostgreSQL includes a variety of ways to import data. Here, we'll show how to import a CSV file from the internet.
For this demonstration, we're going to import batter data from the Baseball Databank, which is in CSV form. While it's easy to import the data using PostgreSQL's COPY command, we'll need to first define a table to put that data into.
We're going to add a database called "baseball," which we'll populate with some Major League Baseball statistics.
Now you can switch to your new (and empty) baseball database.
You can copy and paste this command into your terminal.
Now we can populate the table from the internet using the most recent data.
Just to prove there's data loaded, let's look at the home run leaders for the 1998 season.