Getting Started with PostgreSQL for Windows | 2021

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Postgres a modern relational database for modern developers hi my name is Nelson and in this video I'm going to show you exactly how to download install and configure Postgres on Windows Postgres is by far one of the best relational databases out there and the cool thing about it is that it's open source which makes it a very good fit for your own projects and even startups are even using it in production so that's pretty cool in this video I'm going to show you exactly how to use P SQL which is an interactive shell for connecting to Postgres databases I'm also going to show you how to connect your database using TD admin which is a graphical user interface client and by the end of this video you'll be very familiar on using some credit operations with Postgres if you are a Mac user go ahead and check out my video on how to download and install Postgres for Mac OS otherwise let's go ahead and learn how to download install and configure Postgres on Windows alright so go ahead and navigate to this website we can download Postgres and right here you can see all the versions as well as the operating system so in my case because I'm on Windows I'm going to download the 11.1 version and if you're on Mac go ahead and check out my video where I show you how to do the same but format which is completely different so I already downloaded this executable so what I'm gonna do is close this window and then open this file or executable and then I'm going to say yes just give you a second and there we go so now you see that we have four check boxes the first one is the actual server so this is the Postgres server then the second one is the PG admin client and this is the graphical user interfaces for managing and working with databases and then we have this type builder as well as the command-line tools someone explained in a second what these means but for now go ahead and select all of those and then next now pick a password and this password will be used to connect to your database so whatever you pick make sure to remember so I'm gonna pick my one and then repeat the process next now the port so the default port for Postgres is 5 4 3 2 and pretty much just leave it as it is now you can pick the locale for your database cluster so go ahead and pick yo one but you freedom once you can stick to the defaults I'm gonna press next and then next again and the next and there we go so now that will install just give you a second and we are done so now let's go ahead and take stock builder so this allows you to download additional tools drivers and applications for your PostgreSQL installation so take that and I'm going to show you exactly what this means so go ahead and press finish and then to begin select the installation that you were that you are installing the software so in my case I'm gonna install to my local database but if you had for example a remote server you could pick a remote server so go ahead and press next and now this is what you can pick so you can pick through all these categories but for example if you wanted to experiment with a different database version select a database server and then you could pick you know all of those but you can see that I've got Postgres 11.1 installed so I'm gonna pretty much just close that and now if I press next you will see that you must select at least one package I'm going to press ok because I don't want to select anything and what I'm gonna do is simply cancel out of that so pretty much this console and then prematurely yes and there we go we successfully downloaded and installed Postgres on windows alright so now let's go ahead and connect to our database so go ahead and click on the windows menu and then pretty much just search for P so P so this is the P section right here and you can see that we have post Christ 11 if I open that up and then scroll down you see that we have few things so we have stock builder so you've seen this we have installation notes PG admin so I'm gonna show you how to use this in a second so this is the graphical user interface to manage databases and then we have some documentation right here but then we also have this one right here so this is the SQL shell or most known as p SQL and this is my preferred way to manage databases because using terminal is not scary at all once you know the commands and in fact this is how I learned all the commands and how to work with Postgres just using the shell right for example if you want a remote SSH into a box then you're not gonna have you know all these tools and you know it's always best for you to learn how to use the time you know so let's go ahead and start with the terminal and then I'm gonna show you how to use the graphical user interface called PG admin so what I'm gonna do is grab this and put it on my desktop and let's do the same for PG admin so if I search again for P and then open that Postgres 11 and let's put it right here right so I'm not sure why I don't have the icon but let's go ahead and use P SQL to connect to our database so go ahead and open up P SQL and right here you can see that it's asking for seven so the default is localhost so I'm gonna stick to that and then the database so the default again is Postgres but I'm gonna show you how to create a new database just stick to that and then the poor remember the default port is five four three two and then username is Postgres and right here remember the password that you previously set so this is where you have to use it so I'm going to use my one enter and there we go so now we are inside of this database called Postgres now you can go ahead and premature type help so you can see some help and you can see that these are some of the commands so backslash age for help with SQL commands or backslash question mark for p SQL commands so let's go ahead and look at those so you can see these are some of the PS call commands that you can use so if I press Q to escape out of that and then backslash and then H for SQL commands so you can see all of those commands so if you've done any kind of relational database then you should be familiar with these there we go so I'm gonna press Q to escape out of that so to list all the databases available in this server press backslash L and you can see that we have three databases Postgres so this is the one that we are connected to template 0 and template 1 now what I'm gonna do is create a brand new database so to create brand new database simply type create and then database and then let's call it test end that with a semicolon enter and you can see that we did create the database so if I press backslash L now you can see that we have this database right here called test now what I'm gonna do is I'm gonna close this psql shell and I'm gonna open it again now the server will be localhost and then database instead of Postgres let's go ahead and connect to our test database and then the poll will be the same username will be the same and then the password will be the same so the one that you previously set so I'm gonna press Enter there we go so now you can see that we are connected inside of this database called test now to view any tables or sequences or anything about your database ie describe the database you can press backslash D and you can see that it didn't find any relations so let's go ahead and create a table so create table and let's call this person and then I'm gonna press ENTER to go to the next line and the reason why is not executing this command is because every single command has to terminate with a semicolon and then will be executed so now let's go ahead and create an ID so this person has an ID and the type will be big and then serial and this is an auto increment big integer and then let's go ahead and say that this is not null and will also be the primary and then key and let's also go ahead and say that this person has a name so named and then let's go ahead and say that this is VAR char and then let's go ahead and say hundred characters max and then oh no and let's go ahead and say country so where this person is from so this will also be var and in char and let's go ahead and have 50 right here and finally say not and then no and then what I need to do is end parentheses and then end up with a semicolon and this will be executed so if I press ENTER you can see that create table did work now what I'm going to do is press backslash and then D and there we go so you can see that we are listing the relations so this is the person table and this is the ID sequence remember I said that this big serial is an auto increment big integer and it's managed by this sequence right here if you want to see all the tables backslash D and then T and you can see now we have one table right here called person and the type is table now let's go ahead and insert a few people so go ahead and say insert into and then person and an inside parenthesis we will specify a name and then country so remember the ID is managed by the sequence so we don't have to specify and then values and then what we're gonna do is pretty much just someone so let's go ahead and say amigos and then code and megaliths code is from and then UK so let me go ahead and end out with semi column enter and you can see that what so we have one insert let's go ahead and add someone else so let's go ahead and add Sarah and she's from Albania and then enter you see that works as well let's go ahead and add one more person so Julia and Julius from Argentina and then press ENTER there we go so now let's go ahead and select so select star from and then person you can see that we have three people we can do a count select count and then ID from and then person and you can see that we have three people let's go ahead and update Julio's name so let's go ahead and say that it's no longer Julia so update and then table person set so this is how you update data so we're gonna set the name to equals to Antonio and then we're and then ID equals two and and three enter and it shouldn't be update table should be update person so just let me remove that and an enter you can see that works if I go ahead and press a couple of times to select everyone from person and you can see that now instead of Giulio so right here we had Giulio its Antonio so let's go ahead and delete for example Sara so delete from and then person and then we're ID equals two and then Sara's IDs to enter you can see that works if I select everyone you can see that we only have amigos code and Antonio and pretty much this is it so you basically performed a simple credit operation so create read update and delete so this is pre much the basics of using psql so how to create tables how to insert the leads in so on and so forth so just let me show you one more command so if I press backslash X and you can see that expanded displays on so if I go ahead now and select everyone's in person you can see that I do get my data formatted differently right here and this is useful when you have for example you know tables with large columns where they don't fit on the screen so you can use this expanded display on to turn it off simply press backslash X again and you can see that's off so one more thing I want to show you whit psql is if for example you have large queries so large SQL queries and sometimes it can be tedious to pretty much just to write all those commands here in the terminal so what you could do is execute the command from a foul so I'm gonna open up sublime and then what I'm gonna do is I'm gonna save this file so safe so in my desktop this will be SQL dot SQL so sq all the file name and then the type is SQL so I'm gonna save that now I can go ahead and say select and then let's go ahead and say ID and then name and in the country and on a new line from and in person and then let's go ahead and say we're ID equals to 1 for example right so I'm gonna save this now to execute this what we need to do is open up terminal so I'm gonna open up or actually command line and then I'm gonna not go to desktop and I'm gonna grab this path right here so grab the entire path now if I go back to psql so back slash question mark and right here you see that so if I pretty much just press ENTER a couple of times so you can see input/output and this is how you can execute commands for my file so back slash I and then pass the actual file name so I'm gonna scrape out of that and then press back slash I and then pretty much just paste the entire path and then this will be back slash and then SQL SQL enter and you can see that the permission was denied and this is because I'm using parallels and sometimes there must be like a way of view you know grantee permissions so usually I'm a mark I'm a Mac user but if you want to execute for my file this is how you do it and this is pretty much the basics of using psql now let me go ahead and show you how to use the graphical user interface client so this one right here PG admin so I don't know why I'm not getting the logo but if I search for P so you can see that I'm running parallels so Postgres you can see that we have PG admin for open that up there we go we almost connected and at this point if they asks you for a password go ahead and add the password that you defined previously but for me I think it's not asking me because I've done this step previously so we are good to go now you can see that we have service and then open up Postgres and you can see that we have two databases I'm going to open that up we have Postgres and tests open up tests inside of tests you have you know all kinds of things but open up schema public and then inside we have a few things so we have sequences tables triggers view so on and so forth so what we want is tables and you can see that we have this table called person right and person has three columns so if I expand this you can see ID name and country and you can see indexes rules and triggers and so on and so forth so if you for example wanted to create a new table you could right click on the table create and then table but I you know I usually or actually I've never used this and in fact this is the first time I'm using PG admin just to show you that you can use a graphical user interface client instead of the command line or terminal if you are a Mac user but as I said I recommend you learn how to use the command line so you can create Able's but you can also so if I you know select person and then right-click you can see that you can count rows you can delete you can drop cascade you can truncate you can view data so let's go ahead and view all rows if I call that see it's very slow but you can see that we have two people so and this was the actual query so select star from person and if I pretty much just right-click and then you can use the query tool right there and now we can run query so select and then start from an in person and I usually have these on the line if I pretty much just execute this you can see that it's the same thing and there we go so this is how you get started with Postgres on Windows alright so as you saw post-race is really cool so the next step for you is to enroll to my course wire I cover the fundamentals of using Postgres for both Mac OS users and Windows and it's absolutely free make sure to subscribe to my channel to get more videos like this also go ahead and follow me on my Instagram why the community is growing and if you have any questions go ahead and comment down below otherwise join me in the next one see ya
Info
Channel: Amigoscode
Views: 103,597
Rating: 4.9393382 out of 5
Keywords: PostgreSQL, Programming, Database, SQL Commands, Functions, SQL Queries, SQL Administration, SQL Basics, Advanced, Install PostgreSQL, PostgreSQL 9.6, pgAdmin 4, Windows 10, pgAdmin, How to Install, PostgreSQL 10, pgAdmin 4 on Windows 10, PostgreSQL administration tool, EnterpriseDB, Relational Databases, PostgreSQL 11, How to Install PostgreSQL on Windows, psql, Window Functions, Common Table Expressions, CRUD, SQL CRUD
Id: BLH3s5eTL4Y
Channel Id: undefined
Length: 20min 18sec (1218 seconds)
Published: Tue Feb 05 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.