Insertions that we're not exploring
Inserting data into a table from a file is an advanced level functionality. By the time you need to do that you have a lot of data, and if you do have a lot of data, you will need to wade into the waters of advanced features.
If you'd like to skip ahead, you can read the docs on the sql copy command, or its psql
command line alternative, the\copy
meta command.
The difference between them is that the SQL command (the first one) is going to be significantly faster, but the file you want to use needs to exist on the same machine the database is running on, as it does a local filesystem read.
The \copy
meta command however can take a filepath that sites on your / the client computer, but the downside is that the data needs to pass through the network between the client and the server, which is orders of magnitude slower.