How to Run PostgreSQL in Visual Studio Code

TutorialBrain
18 Apr 202222:31

Summary

TLDRThis video tutorial demonstrates how to install and set up PostgreSQL in Visual Studio Code. It walks through the process of downloading PostgreSQL, installing it on different operating systems, and setting up databases using both SQL Shell and pgAdmin. The tutorial also covers how to use PostgreSQL extensions in VS Code to connect to a local database, create tables, and run SQL queries. Additionally, the presenter introduces two useful PostgreSQL extensions and explains how to effectively work with databases in VS Code, offering multiple options for users based on their preferences.

Takeaways

  • 🖥️ The video shows how to install and set up PostgreSQL in Visual Studio Code (VS Code).
  • 💡 The creator plans to make courses on Visual Studio Code and PostgreSQL, encouraging viewers to subscribe for updates.
  • 🌐 The first step is to download PostgreSQL from the official website, selecting the appropriate version for your operating system.
  • 🔑 During installation, the user sets a password for the PostgreSQL database, and the default port is 5432.
  • 📂 The video shows how to access PostgreSQL tools like pgAdmin and SQL shell for database management.
  • 🛠️ PostgreSQL can be accessed via pgAdmin or psql commands to perform SQL operations like creating databases and tables.
  • 🔗 The video introduces the VS Code extension for PostgreSQL (by Chris Kolkman) to connect and manage databases directly in the editor.
  • 🚀 The process of creating tables, inserting data, and running SQL queries within VS Code is demonstrated step by step.
  • 🔄 Another PostgreSQL extension for VS Code is also recommended, supporting multiple databases like MySQL and MongoDB.
  • 📚 The creator hints at a full course on PostgreSQL and asks viewers to like and subscribe for future content.

Q & A

  • What is the main objective of the video?

    -The main objective of the video is to demonstrate how to set up and run PostgreSQL on Visual Studio Code, as well as to inform viewers about upcoming courses on Visual Studio Code and PostgreSQL.

  • What is the first step in setting up PostgreSQL as mentioned in the video?

    -The first step is to download PostgreSQL by visiting the official website and selecting the installer file based on your operating system.

  • What is the default port number for PostgreSQL, and when might it change?

    -The default port number for PostgreSQL is 5432. In rare cases, it might change to 5433.

  • How do you connect to a PostgreSQL server locally using the SQL shell?

    -You connect by using the default settings: server as 'localhost,' database as 'postgres,' port as '5432,' and username as 'postgres.' You will need to enter your password to complete the connection.

  • What tools are mentioned for interacting with PostgreSQL besides the SQL shell?

    -The tools mentioned are PGAdmin 4, a graphical user interface for managing PostgreSQL, and extensions for Visual Studio Code like PostgreSQL Explorer.

  • What steps should be followed to install the PostgreSQL extension in Visual Studio Code?

    -You should open Visual Studio Code, go to Extensions, search for 'PostgreSQL,' and install the extension by Chris Kolkman. After installation, reload the Visual Studio Code window.

  • How do you create a new table in PostgreSQL using Visual Studio Code?

    -After connecting to a database in Visual Studio Code, you can create a new table by writing an SQL query, such as `CREATE TABLE emp (emp_id INTEGER, emp_name VARCHAR(50), emp_address TEXT);` and running it with F5 or the Run Query option.

  • How can you view existing databases and tables in PostgreSQL through Visual Studio Code?

    -You can view existing databases and tables by clicking the PostgreSQL Explorer in Visual Studio Code and expanding the database and schema tree to see the tables and their data.

  • What alternatives are provided if the first PostgreSQL extension doesn't work in Visual Studio Code?

    -If the first extension doesn't work, the video suggests installing another PostgreSQL extension by Sweizan, which supports multiple database types including PostgreSQL and offers additional features.

  • Why is Visual Studio Code considered a good option for working with PostgreSQL according to the video?

    -Visual Studio Code is recommended because it allows users to run SQL queries, manage databases, and create tables directly within the IDE without needing to switch to other tools like PGAdmin or SQL shell.

Outlines

00:00

🚀 Introduction and Objectives of the Video

The creator introduces the purpose of the video, which is to show how to run PostgreSQL on Visual Studio Code. The creator also mentions plans to create courses on both Visual Studio Code and PostgreSQL, encouraging viewers to subscribe for future notifications. The video begins with a promise to provide multiple methods for setting up PostgreSQL, emphasizing the importance of watching until the end to avoid any issues during installation.

05:02

🖥️ Installing PostgreSQL Database

The first step in the video is to download the PostgreSQL database. The creator demonstrates how to find the download link on the official website and select the appropriate installer for the operating system. Detailed instructions are given for installing PostgreSQL version 14.2 on a Windows machine, including setting up the installation directory, choosing the default port (usually 5432), and specifying a password for connecting to the database. The creator also explains using Stack Builder to connect to the server and concludes by verifying the installation through PG Admin 4 and the SQL Shell.

10:03

🗃️ Creating and Managing Databases in SQL Shell

The creator demonstrates connecting to PostgreSQL using SQL Shell, showing how to interact with the database through various commands. Commands like `\l` to list databases, and SQL commands to create a new database (e.g., `CREATE DATABASE dev;`) are explained. The newly created database is verified, and the creator highlights the use of SQL Shell for managing databases and tables directly, including connecting to and working with specific databases using simple commands.

15:05

🛠️ Setting Up Visual Studio Code for PostgreSQL

The creator provides detailed steps to set up PostgreSQL in Visual Studio Code by installing a specific extension (`PostgreSQL` by Chris Kolkman). The installation process is demonstrated, followed by instructions to connect to PostgreSQL through the extension. The video guides viewers on creating and running SQL queries within Visual Studio Code, including creating tables (`CREATE TABLE emp ...`), inserting records (`INSERT INTO emp ...`), and verifying the changes. It is highlighted how Visual Studio Code allows for convenient database management without needing additional tools.

20:08

🔄 An Alternative PostgreSQL Extension for Visual Studio Code

The creator introduces another PostgreSQL extension for Visual Studio Code as an alternative (`PostgreSQL` by Sweizan), which also supports other databases like MySQL, SQL Server, and SQLite. The setup and connection processes are similar to the previous extension, and the video highlights the features of this new extension, including database exploration, viewing table structures, and other operations like dropping tables or adding columns. The creator concludes by summarizing the different methods for running PostgreSQL and encourages viewers to subscribe for more tutorials.

Mindmap

Keywords

💡PostgreSQL

PostgreSQL is an open-source relational database management system (RDBMS) that emphasizes extensibility and SQL compliance. In the video, PostgreSQL is the central tool being installed and configured within Visual Studio Code (VS Code), where the user demonstrates how to set it up, run queries, and perform database operations.

💡Visual Studio Code (VS Code)

Visual Studio Code (VS Code) is a popular lightweight code editor developed by Microsoft. It supports numerous programming languages and offers various extensions. The video focuses on integrating PostgreSQL with VS Code, showing viewers how they can manage databases directly from this editor using extensions.

💡PG Admin

PG Admin is a web-based graphical user interface (GUI) tool that allows users to manage PostgreSQL databases. In the video, PG Admin is introduced as an alternative method to connect to and manage PostgreSQL databases, highlighting its ease of use for performing SQL operations and viewing database details.

💡Extensions

Extensions in VS Code add functionality to the editor, allowing it to support additional languages, frameworks, or tools. In this video, the presenter installs a PostgreSQL extension by Chris Kolkman, which provides an SQL Explorer feature, enabling the connection and management of PostgreSQL databases from within VS Code.

💡Database

A database is an organized collection of data that can be easily accessed, managed, and updated. The video demonstrates how to create, connect to, and manage PostgreSQL databases using various tools, such as the SQL cell, PG Admin, and VS Code's PostgreSQL extensions.

💡SQL

SQL (Structured Query Language) is the standard language for managing and manipulating relational databases. Throughout the video, the presenter uses SQL commands like CREATE DATABASE, CREATE TABLE, and SELECT to perform operations in PostgreSQL, showcasing its importance in database management.

💡PSQL

PSQL is the command-line interface for interacting with PostgreSQL. In the video, the presenter uses PSQL to connect to the PostgreSQL database, run SQL commands, and perform operations such as creating tables and inserting data. It's introduced as a tool for users who prefer command-line interaction over graphical interfaces.

💡localhost

Localhost refers to the local machine or server where PostgreSQL is running, often represented by the IP address 127.0.0.1. The video frequently refers to localhost when connecting to PostgreSQL from tools like PSQL and VS Code, emphasizing that the database is being hosted locally.

💡SQL Query

An SQL Query is a request made to the database to retrieve, insert, update, or delete data. In the video, SQL queries are demonstrated for actions like creating tables, inserting data into them, and retrieving records using the SELECT command. These queries form the foundation of how the presenter interacts with PostgreSQL.

💡Port 5432

Port 5432 is the default communication port for PostgreSQL. The video mentions this port multiple times when setting up PostgreSQL connections, ensuring that the database is accessible through this port when connecting from PSQL, PG Admin, or VS Code.

Highlights

Introduction to running PostgreSQL on Visual Studio Code.

Announcement of future courses on Visual Studio Code and PostgreSQL.

Step-by-step guide on downloading PostgreSQL via official website.

Explanation of PostgreSQL installation process and setup for Windows.

Detailed instructions on setting up a database password and configuration settings.

Insight into default PostgreSQL port settings (5432, occasionally 5433).

Using pgAdmin to connect to the PostgreSQL database locally.

Introduction to using psql tool for connecting and managing PostgreSQL databases.

Creating and verifying a new database (named 'dev') in PostgreSQL using SQL shell.

Connecting to PostgreSQL via pgAdmin, and managing databases through the interface.

Installing Visual Studio Code extension for PostgreSQL (recommended from Chris Kolkman).

Reloading Visual Studio Code and verifying PostgreSQL Explorer setup.

Demonstration of creating and inserting records in a table ('emp') via Visual Studio Code.

Using an alternative PostgreSQL extension (from s w e i z a n) for extended compatibility.

Overview of managing databases, including creating tables and records, entirely within Visual Studio Code.

Summary of options to work with PostgreSQL (pgAdmin, SQL shell, or Visual Studio Code).

Transcripts

play00:00

in this video i will show you how you

play00:02

can run postgresql on visual studio code

play00:05

and if you want to master visual studio

play00:07

code or postgresql then i am planning to

play00:10

create courses on visual studio code as

play00:12

well as postgresql so what you have to

play00:14

do is you just have to subscribe to our

play00:16

channel so that once the videos are

play00:19

published you will get further

play00:20

notification so without wasting much

play00:22

time let's get started

play00:25

[Music]

play00:30

all right i will share multiple ways

play00:33

using which you can install or you can

play00:35

set up your postgresql in vs code so

play00:38

watch the video till end so that you do

play00:41

not face any issues so let's start all

play00:44

right so the very first step is to

play00:45

download postgresql database so in your

play00:49

favorite browser in my case i have

play00:51

google chrome just type download

play00:53

postgresql and the link you get is

play00:56

www.postgresc

play00:58

this is the official website and you

play01:01

just come here and based on your

play01:03

operating system you can download the

play01:05

installer file in my case i have windows

play01:08

i'll just click on this windows button

play01:10

it will lead to this particular place

play01:12

and i'll just click on this download the

play01:14

installer

play01:15

and it will lead to an external website

play01:18

that is enterprise db.com because they

play01:21

are maintaining this

play01:23

so at this moment while recording this

play01:25

video

play01:26

the postgresql version is 14.2

play01:29

so based on my operating system so in

play01:31

case of windows you can click here if

play01:33

your mac you can download from here in

play01:36

case you have linux then you can

play01:38

consider clicking on this particular

play01:40

link so let's click on this particular

play01:42

link so that i'll download the installer

play01:45

file for windows

play01:47

so the file is downloaded i'll just

play01:50

click on this executable file

play01:52

click on next you have to select the

play01:54

installation directory i'm not going to

play01:56

change this so you can see that it is

play01:58

going to settle in program files

play02:00

postgresql and the version at this

play02:02

moment is 14.

play02:04

i'll check all these so by default all

play02:06

these options are checked and i'll just

play02:08

click on this next

play02:10

again i'll just click on next

play02:13

and you can give the password so this is

play02:15

the password using which you will

play02:16

connect to your postgre sql so do not

play02:19

miss it so i'll just give a password

play02:21

simple password

play02:22

and

play02:24

i'll just click on next

play02:26

you remember that for postgresql the

play02:29

port is 5432 in few of the rare

play02:32

scenarios it will be 5433 so i'll just

play02:35

click on next

play02:37

and you see here it is giving a lot of

play02:39

options for locale i'm not going to

play02:41

change this and i'll keep the default

play02:43

local

play02:44

click on next

play02:46

and again i'll just click on this next

play02:48

button and it is ready to install

play02:55

now you can see that it is finished

play02:58

this option should be checked and this

play03:00

is stack builder and i want this click

play03:03

on finish

play03:06

and now you see that it says which is

play03:08

the server you want to connect so in my

play03:10

case i have postgre sql 14 i'll just

play03:13

click on this i mean i'll just select

play03:15

this and if you want to connect to a

play03:17

remote server you can have this

play03:20

particular option but in that case you

play03:22

should be having all the details of that

play03:24

particular remote server in my case we

play03:26

will be installing this on our local

play03:28

machine that's the reason we'll select

play03:31

the second option

play03:32

click on next

play03:34

and it is going to download

play03:36

these options and actually these all

play03:39

options are not required so

play03:41

what you can do is you can just cancel

play03:43

it okay

play03:44

and i'll just click on this yes

play03:46

all right now what i'll do is i'll just

play03:48

go to this particular option

play03:50

that is start and i'll just come down

play03:53

and i should be having p right you see

play03:56

here under p i have postgresql and these

play04:00

two tools are very important under this

play04:02

first one is pga admin 4 using which you

play04:04

can connect to database and you can

play04:07

write the sql commands and you can

play04:08

perform lot of sql operations the other

play04:11

one is sql cell so if i just click on

play04:13

this sql cell using this sql cell also i

play04:16

can connect to my postgre sql database

play04:19

you see here it says server as localhost

play04:22

i'm not gonna change it please remember

play04:23

it is localhost

play04:25

database is postgres please remember i'm

play04:27

not gonna change it at this moment

play04:29

port is 5432 so i'm not gonna change it

play04:32

username is postgres please remember i'm

play04:35

not gonna change this at this moment and

play04:37

password you can give your own

play04:39

and please remember this password using

play04:41

which you will connect to your database

play04:43

so i'll just give here

play04:45

a simple password please remember this

play04:47

and now what i'm gonna do is you see

play04:49

here it says type help for help now just

play04:52

type help and you see that it gives few

play04:55

options for example backslash h is for

play04:58

all the sql commands

play05:00

backslash question mark is for all the

play05:02

piece sql commands and so on so let's

play05:04

say that if i just give backlash edge

play05:06

you see that all these options are

play05:08

related to my database all right if i

play05:11

just give q q is for coming back or

play05:14

escape so if i just give q

play05:16

you see that i have just come back and

play05:19

what i can do is for example i can just

play05:21

give backslash l to check the current

play05:23

databases

play05:25

now you see i have three database at

play05:26

this moment and if you want you can

play05:29

create your own database for example i

play05:31

can just give here create

play05:33

database

play05:35

and i can give name of a database for

play05:37

example

play05:38

dev and then semicolon at end

play05:41

you have enter

play05:43

and just wait for some time

play05:45

so that it creates a database for you

play05:48

now you see that this particular create

play05:50

database has worked and it has created

play05:52

one database if i just give back class l

play05:56

you see that now i have four rows and

play05:58

this is the database which is created so

play06:00

i just wanted to show you something

play06:02

about psql and let's say that if i just

play06:05

close this

play06:06

and i just forgot to tell you okay i'll

play06:08

just show you again

play06:10

uh if i just go to

play06:12

psql again so let me just open this if i

play06:14

just go to p

play06:17

i'll just come here and you see you can

play06:19

have a shortcut for this as well but i'm

play06:22

not going to create any shortcut at this

play06:23

moment click on this

play06:25

give enter

play06:26

database this time i'll just give div

play06:29

because i want to connect to dev

play06:30

database only give enter port is fine

play06:34

username is also fine password i'll give

play06:36

my password

play06:38

now you see that i have connected to

play06:40

this particular database so at this

play06:42

moment i do not have any record or i i

play06:45

do not have any tables in this

play06:46

particular database now i just wanted to

play06:49

show you that you can connect to your

play06:51

own database only using sql cell now

play06:54

let's close this

play06:55

okay now

play06:57

i'll just show you another option using

play06:59

pg admin

play07:01

i should be having pg admin

play07:03

so under postgresql you see i have pg

play07:06

admin 4 and you can connect the database

play07:09

using this pd admin 4 as well

play07:14

so it is asking to set a master password

play07:16

i'll give a particular password

play07:20

and now you see here

play07:22

i have these servers if you just click

play07:24

on the servers

play07:25

i have postgresql 14 and i'll just give

play07:29

password so this is the password which

play07:31

you have to give to connect to

play07:32

postgresql server and i ask you to

play07:35

remember this password just give okay

play07:37

and you can see that you have lot of

play07:39

details in this particular tool

play07:41

so this is a very good tool and in fact

play07:43

i'm going to have a particular course on

play07:46

postgresql where i'll be using this

play07:48

particular tool so if you want to check

play07:51

that particular course you can check the

play07:52

description of this video and you might

play07:54

get the link by the time you'll see this

play07:56

video all right and if i just go to this

play07:59

databases if i just click on this

play08:01

databases

play08:03

you see i have two database at this

play08:06

moment one is postgres and one is dev so

play08:09

you see there is a question mark here

play08:11

because i have not connected to this if

play08:12

i just click on this particular database

play08:14

so you see that it says please connect

play08:16

to the selected server to view the

play08:18

dashboard so at this moment there are no

play08:20

tables so i'll just close this but this

play08:24

is the default database that is postgres

play08:27

and if i just click on this if i just go

play08:29

to schema

play08:31

you see i have this public and under

play08:34

this public if i just come down i have

play08:36

tables

play08:37

if i just click on this particular table

play08:39

and now

play08:40

you see that i have query tool i have

play08:43

psql tool i have reference button and i

play08:45

can create a table right so at this

play08:48

moment for this particular database

play08:50

under tables again we don't have a table

play08:52

so if you want you can create a table

play08:54

itself

play08:55

so just give right click and you can

play08:57

click on create table

play08:59

and

play09:00

you can create a table using this but

play09:03

this video is not about pg admin 4

play09:05

rather we will be using the visual

play09:07

studio code to connect to postgresql

play09:10

database and we will be creating our

play09:12

table or in fact we can create databases

play09:15

and we can perform lot of other

play09:17

operations i mean sql operations using

play09:20

visual studio code so first i'll just

play09:22

close this

play09:24

again i'm gonna close this

play09:27

and what i'll do is first i should be

play09:30

having visual studio code so i'm sure

play09:33

that you guys are having visual studio

play09:35

code if you do not have it go to this

play09:37

link that is code.visualstudio.com

play09:40

and you can download the visual studio

play09:42

code based on your operating system for

play09:45

windows you can download from here for

play09:47

mac you can see that the stable version

play09:50

is here and for linux you can download

play09:52

from here all right if you want to

play09:54

install a fresh installation of visual

play09:56

studio code make sure that

play09:58

normally you check all these four

play10:00

options i always suggest this okay let

play10:03

me just close this and just open your

play10:06

visual studio code and what you can do

play10:08

is first the very important step is that

play10:11

go to extensions

play10:12

and i'll tell you to install one

play10:15

extension so if i just search for post

play10:18

gray sequel you see the first one okay

play10:22

so this is a very good extension

play10:24

and this is from chris kolkman please

play10:27

note that there is another extension

play10:29

that is this

play10:31

sql extension from microsoft do not

play10:33

install it and this is not a very good

play10:35

extension in fact you can install the

play10:38

previous one from chris kolkman just

play10:40

click on install button and i'll show

play10:43

you how easy it is to connect to

play10:45

postgresql using this extension i always

play10:48

suggest that whenever you install an

play10:50

extension you should reload your visual

play10:53

studio code so i'll just give shift

play10:55

control and p to open the command

play10:57

palette and here i'll just give

play11:00

developer reload window so that my

play11:03

visual studio code is refreshed

play11:04

automatically now you see that my

play11:06

extension is installed and i'll just

play11:09

click on this explorer button

play11:11

and you see here i have four sql

play11:14

explorer you see this elephant icon just

play11:17

click on this and you see at top you

play11:20

have postgresql explorer just click on

play11:22

this plus button

play11:24

and

play11:24

you can give the host name so by default

play11:27

it is

play11:29

127.0.0.1 or you can just give localhost

play11:34

localhost

play11:36

and you can give the name of the user if

play11:38

you remember the name of the user was

play11:40

postgres so i'll just give postgres

play11:43

give enter you can give the password

play11:45

using which you have to connect the

play11:46

postgre sql database i'll just give my

play11:50

password

play11:51

and you should have remembered this

play11:53

password

play11:54

and 5432 is the port

play11:57

and

play11:58

it gives two options

play12:00

you want to connect using secure

play12:01

connection so do you have a server for

play12:04

which you have a secure connection or

play12:06

for localhost it is always suggested you

play12:09

go for standard connection so if i just

play12:12

click on this standard connection now

play12:14

you see that it says show all databases

play12:16

or postgres or dev so if you remember we

play12:19

create this dev database using sql cell

play12:23

so that is the reason it is showing this

play12:24

particular database as well if you do

play12:26

not create that database it will only

play12:28

show postgres so i'll just click on this

play12:31

show all databases

play12:33

and now what is the display name or

play12:35

label you want to keep so i'll just give

play12:38

for example

play12:39

localhost

play12:42

post

play12:44

graysqldb

play12:46

give enter so this is just a display

play12:49

name you can give your own name so you

play12:51

see the same display name is coming here

play12:53

i'll just click on this

play12:55

arrow and i have two databases the first

play12:58

one is dev and the other one is postgres

play13:01

so first i'll just show you how to

play13:02

connect to postgres now see that if i

play13:04

just click on this and at this moment i

play13:07

think i don't have now first let me just

play13:09

create a table so this is the default

play13:11

database that is posted this what i'll

play13:13

do is i'll create tables on our database

play13:16

which we created so you see this is the

play13:19

database which we created that is dev so

play13:22

you just give right click and you see

play13:24

new query

play13:26

and you can create a table so i can just

play13:28

give for example create

play13:30

table

play13:32

and name of the table so i'll just give

play13:34

for example let's say i want to create a

play13:36

table for employees so i'll just say

play13:39

emp

play13:41

so this is for employee table

play13:44

and i'll just say for example

play13:46

employee id and i'll just give for

play13:48

example integer

play13:52

okay i'll just give integer

play13:55

and

play13:55

now let's say

play13:57

i'll just have employee name

play14:00

so employee name i'll just give for

play14:01

example text field or it is better i'll

play14:04

just give where care

play14:07

of let's say 50

play14:09

and again i'll be having for example

play14:12

employee address

play14:15

and i'll just give a text field

play14:17

so that i should not be worried about

play14:19

the length

play14:20

and attend i'll just give a semicolon

play14:23

and you see i'll just give right click

play14:25

and i'll just give run query you can

play14:27

give f5

play14:28

in keyboard so once i run this

play14:32

you see it says null rows created that

play14:34

means the table is created but there are

play14:36

no records

play14:37

now i'll just comment it out

play14:40

first let me insert few records in the

play14:42

table so i'll just give insert

play14:46

into this particular table that is emp

play14:49

and i'll just give emp id

play14:52

comma emp name

play14:54

comma emp

play14:57

address

play15:00

and i'll just give values

play15:03

so i'll just give for employee id for

play15:04

example one for employee name i'll just

play15:07

give for example

play15:09

sandy

play15:10

and

play15:12

for this particular employee address

play15:13

i'll just give a dummy address

play15:17

okay

play15:18

and

play15:20

now

play15:21

if i just run this so i'll just give f5

play15:25

and it says sandy does not exist so

play15:28

there is a problem so okay let me do one

play15:30

thing

play15:31

i'll just give in single quote actually

play15:33

sorry for that

play15:35

and here i should be giving in single

play15:38

quote

play15:39

and if i just give f5

play15:41

you see it says one row is created again

play15:44

i'll just give here two

play15:46

and i'll just give for example let's say

play15:48

mandy

play15:50

and i'll just give dummy street two and

play15:52

again i'll run it

play15:54

so again it will create another record

play15:57

now i'll just comment it out

play16:00

and if i just give

play16:02

select

play16:04

star

play16:05

from

play16:07

name of the table which is emp

play16:10

now if i just

play16:11

run this

play16:13

you see i have two records

play16:15

that is employer id employee name and

play16:17

employee address and it is showing

play16:19

employee id one two sandy mandy and then

play16:22

it is showing the corresponding address

play16:25

now if i just come here in the div you

play16:27

see if i just refresh it

play16:30

you see under public i should be having

play16:33

a table you see in emp

play16:35

and if you just give right click

play16:37

you can just select

play16:39

top

play16:39

1000 records or some top record for

play16:42

example if i just want to select top

play16:44

thousand records i i'll just give here

play16:46

i'll just select on this and it will

play16:48

give me top thousand records since we

play16:50

have only two records that is the reason

play16:52

it is displaying only two records so

play16:54

this is how you can create tables in

play16:57

fact you can perform all the operations

play16:59

for example alter you have drop you have

play17:01

delete so all the sql statements you can

play17:04

perform using this visual studio code

play17:06

and you do not have to connect to pj

play17:09

admin or sql cell and in fact you can

play17:12

create your own database here itself so

play17:14

i'll just give right click

play17:16

and you see here it says you can edit

play17:18

this connection you can rename it you

play17:20

can have new query so if i just give new

play17:22

query

play17:23

i can create my own database so i can

play17:25

just give here create

play17:27

database

play17:28

this time i'll just give the name of the

play17:30

database as prod okay and i'll just give

play17:34

here database

play17:36

and if i just give f5 or run query

play17:40

you see it says waiting for query to

play17:42

complete it will take some time because

play17:44

it is creating a database which involves

play17:46

lot of indexes clusters and so on so

play17:49

that is the reason it is going to take

play17:51

some time now it says null rows created

play17:54

now you see here if i just refresh it

play17:57

now

play17:59

you see

play18:00

i have dev and prod again

play18:03

if you just come here you can have a new

play18:05

query and you can create tables here

play18:07

now if for some reason this particular

play18:10

extension is not working for you i'll

play18:12

tell you another extension which is

play18:14

extremely good

play18:15

so go to extension manager again

play18:18

give post

play18:20

gray sql

play18:23

and you have this particular extension

play18:25

that is postgresql from s w e i z a n so

play18:30

this is an awesome extension which i

play18:32

have myself tested it out and it behaves

play18:35

in a very perfect manner i'll just click

play18:37

on this install button

play18:39

now it is installed i'll just go to

play18:40

command palette and i'll reload the

play18:43

window again so that whatever extension

play18:46

i'm uploading or i'm adding it should

play18:48

behave in a proper way

play18:51

all right and now you see that

play18:53

once you install this extension it is

play18:56

going to create two particular icons so

play18:59

here it is database explorer and at the

play19:02

bottom it is other explorer so the

play19:04

database explorer i'll just explain

play19:06

first

play19:07

and you see first let me just come to

play19:09

this particular option that is explorer

play19:12

click on this database explorer and you

play19:14

see here you can connect to github as

play19:16

well and you can refresh and there are

play19:19

other options which i'm not gonna talk

play19:21

just click on this plus so that you can

play19:23

add your own connection so if i just

play19:25

give plus

play19:27

first let me just close the previous one

play19:30

it is not required

play19:32

and

play19:33

now this is also not required

play19:38

this is also not required

play19:41

okay now you see if i just click on this

play19:43

plus button

play19:44

i'm getting this option that is

play19:46

connected to database server the beauty

play19:48

of this extension is that it is

play19:49

supporting different different databases

play19:51

for example mysql postgresql sql server

play19:55

sqlite mongodb and so on since this

play19:58

video is all about postgresql i just

play20:01

click on this postgresql and hostname

play20:04

either i can just give 127.0.0.1

play20:07

which corresponds to localhost if you

play20:10

remember port was 5432 username was

play20:14

postgres you have to give the password

play20:15

using which you have to connect to

play20:17

postgresql so i'll just give my password

play20:20

and if you remember i told you to

play20:21

remember this password and i'll just

play20:24

click on this

play20:25

connect option you see databases and all

play20:27

you don't have to change because i'm

play20:29

going to connect to postgres if you want

play20:31

to connect to different database you can

play20:33

give that particular database name here

play20:36

okay just click on connect now

play20:39

and now we see that i have these three

play20:41

databases now in the same way you can

play20:43

perform all the operations here so for

play20:46

example let's say that i was into dev

play20:49

and i was into this particular public

play20:51

right

play20:52

and we created this table that is emp

play20:55

now you see if i just give right click

play20:57

you see there are a lot of options here

play20:59

now you can drop the table you can

play21:01

generate the mock data you can add a

play21:03

column using alter command and so on and

play21:05

you see if i just click here see this

play21:07

has given me the details of this

play21:09

particular table i mean how many records

play21:11

this particular table contains so this

play21:13

is a very clean interface

play21:15

and if the previous extension is not

play21:17

working for you you can install this

play21:19

extension and it will behave in a very

play21:21

good manner

play21:22

so that's it in this video i hope you

play21:25

enjoyed this video

play21:26

and i have given multiple ways of

play21:28

running postgresql commands for example

play21:31

you can run it using a sql cell you can

play21:34

run it using pga admin and in fact the

play21:36

best way is that you can connect with

play21:38

visual studio code itself if you are a

play21:40

vs code lover and you can install either

play21:43

one of the extensions and you can work

play21:46

in a very proper way without any issues

play21:48

with postgresql so that's all if you

play21:51

like the video or the video was helpful

play21:53

please hit on the like button and if you

play21:55

want to watch the complete tutorial on

play21:57

postgresql do subscribe to our channel

play22:00

so that once i publish that video you'll

play22:02

get the notification and that's it keep

play22:05

on practicing i'll meet you in our next

play22:07

video till then take care bye

play22:11

[Music]

play22:21

hold me close till i get up

play22:24

time is

play22:27

[Music]

Rate This

5.0 / 5 (0 votes)

Связанные теги
PostgreSQL setupVS Code tutorialDatabase installationSQL commandsProgramming guidePostgreSQL courseVS Code extensionsDatabase managementTech tutorialsSQL basics
Вам нужно краткое изложение на английском?