Import CSV file into PostgreSQL with PgAdmin

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i'm going to show you how to import a csv file into postgres sql using pg admin 4. so the first thing that you want to do and so you can see that i have like the databases and then i created this test database where i'm going to import the csv file and so if i go down here to schemas and then tables notice how when i expand the tables there's no tables in this database yet so i need to create a table and then i'm going to import the csv data into that table so i'm going to right click on tables go to create table and then i need to give the table a name so i'm just going to call the table test data i think everything else can just stay how it is depending on what you need you might need to change some of these things but what you do need to do is put in column names if i look at the data that i'm importing so this is my csv file and notice how my column names are x and y and go back up here so i need to specify these column names and the other thing i need to do is i need to specify the data type that i have in the table for each column so if i go back to here go to add and the first column was named x as far as data type these were integers so i'm going to put integer and then i need to add the y column and then the y is also the data in the y column is also an integer based put that and then none of these are a primary key so i don't need to worry about that you can look through some of these other things the one thing to look at is you can create this with sql code so just keep in mind that this code is here to create the table so save that so if you were to go to table and then you can go to the query tool and you could technically you could put that code in directly to create the table so that's another way that you can create a table all right so we have our table created right here now what i want to do is import the data so i'm going to right click on my table name which is test data and then go to import export and i want to change this box here that says import export to import i need the file name so i'm going to go find it and it's actually already here so select that and select and then and the other thing is i want to show you this you can either go through so if you click on these three dots you can either go through these menu system to find your file and or which is what i did or the other thing you can do is if you find the file so this is where the file is so if i right click on the file i can go to properties and then get the path from here so the location and then you can just copy and paste this path directly into pg admin 4 for right here for your file name okay and then it's a csv file and it has headers so i need to select yes on that and then you need to select the delimiter so since it's a csv file the delimiter is a comma and then say okay and it's showing that it successfully completed so i can check and see and it looks like the table has columns now and the columns are x and y so i can go into the query and just verify that it imported the data from the csv file so i can say select i'm going to select all columns from and then the table name is test data hit run and there it is so this is the data so i have the x and y columns and the data that was imported from that csv file if you found this video helpful please hit like or subscribe and thanks for watching
Info
Channel: Raili Taylor
Views: 63,228
Rating: undefined out of 5
Keywords:
Id: 6Jf7eTkIaR4
Channel Id: undefined
Length: 5min 26sec (326 seconds)
Published: Tue Dec 14 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.