In this video, we will learn everything about PostgreSQL databases and tables from scratch. You'll understand database theory, create and drop databases using PostgreSQL CLI (psql) and pgAdmin4, connect databases, list all databases, create tables properly, understand rows and columns, and learn important PostgreSQL best practices developers actually use.
🔥 What you will learn:
✅ What is a database and table in PostgreSQL ✅ Create database in PostgreSQL using CLI ✅ Connect and list databases in PostgreSQL ✅ Drop database safely ✅ Create database using pgAdmin4 ✅ Create tables in PostgreSQL ✅ Table creation syntax explained ✅ Hidden trick to show all tables ✅ Best practices while designing tables ✅ PostgreSQL tips beginners never learn
This tutorial is beginner-friendly and perfect for students, developers, React developers learning backend, and future full-stack engineers.
⌛TIMELINE⏳ 0:00 Introduction — Database & Tables Explained 0:30 Database Theory: What Actually Happens Behind the Scenes 1:50 Connect & List Databases using psql 2:40 Create & Drop Database Without Connecting 3:20 Support the Channel ❤️ 3:45 Create and Drop Database using PostgreSQL CLI 5:30 PostgreSQL Secret Nobody Tells Beginners 7:10 Connect to a Specific Database 8:10 Create Database Using pgAdmin4 9:50 Delete Database using CLI & pgAdmin 12:10 Database Tables Theory — Row, Column & Schema 14:50 PostgreSQL CREATE TABLE Syntax Explained 15:30 Best Practices Before Creating Tables 18:15 Create Tables in pgAdmin4 21:18 Hidden Trick — Show All Tables in PostgreSQL 23:40 Important PostgreSQL Tips Developers Follow 25:35 Practice Task For You
AI Generated·May contain errors
Video Summary
AI Generated
This tutorial provides a comprehensive guide to managing PostgreSQL databases and tables using both the Command Line Interface (CLI) and pgAdmin 4. Using a \"College Management System\" example, it covers essential SQL syntax for creation and deletion, data type selection, and industry best practices for database structuring and naming conventions.
Hello, what's up, guys?
Welcome to day 3 of the PostgreSQL series
So in this video we are going to see
How to create a complete database
And how to create tables
We're going to see all of that in this video.
Both in your CLI
Command Line Interface
And your GUI
I'm going to tell you in both
So let's start the video
Let's see
How to create a database
In your PostgreSQL
PostgreSQL
If we want to create a database
You can see the command here
Queries or syntax
If you want to
Create a database
It's very simple
The query is the same.
The query is your created database.
Simple
Create database and database name
Your database is ready.
And there is one more way
To create a database
If you don't want errors
You can
Create if not exists
And don't worry
I will show you the theory first.
So that you can understand
We will do the same with tables
You can see very clearly
Writing is the same.
The only thing is
If not exist
Means
You have to create a database.
If that database
Does not exist
That's it
You won't get any error
If not exist
The database will be created.
If exist
It will not be created
And one thing
PostgreSQL version 17
And above that
This query command will work.
Here people are confused.
About two things
That is how to connect without a database
You have to write
Backslash
And then C
C means connect
I have to connect
With my database
Simple
Here hyphen C
And then
People are confused
How to view the database
In MySQL
Show database
You have to write
Backslash and then L
L means list
All databases
You can see more things
When we talk about tables
It's different
You can see some commands
Slash C
Backslash
Slash
Backslash C and Slash L
Connection list
If you want to drop the database
Simply drop the database
Otherwise
Drop database
If exist
If not exist
I won't say
If not exist
How to delete
When you create
If not exist
Create
If exist
Delete
This is your database
Before going to tables
Let's create our database
In PostgreSQL
Are you excited?
I am super excited
We are going to create our first database.
Before that
If you haven't subscribed to my channel
.try to subscribe
Our next target is 800,000 subscribers
If you don't like this video
Please subscribe
We have our CLI的整体
This is your CLI
Command line tools
Finally
We will create our database
With PG admin
That's your GUI
Throughout this course
We will play with PG admin
First of all
You have to connect your user
That's your Postgres
You have to write a password
That's your super user password
When you write backslash L
It shows
What database have you created?
In your Postgres
So many
You can see here
So many
My app
Test
So many
Let it be
Now we have to create our database
It's super easy
The rule states
When you are creating a database
CAPITALIZE YOUR KEYWORDS
And then
Names of tables
Names of fields
Create database
Write here
For now
College
College administration
Don't forget
Use a semicolon.
If you don't use a semicolon
And press Enter
I showed you yesterday
It goes in waiting
End this line
I give semicolon
Now my database has been created.
I have to see.
Backslash L
College administration
I created it recently
Now something interesting
Something interesting
I think you haven't seen it.
When you create
There is a way in CLI.
To know
Current active database
Do you understand?
See command
Select
Current
Current database
And give a semicolon
So right now
The current database is your PostgreSQL.
Because up until now, I haven't connected anything yet
And here was a way
You can also do it yourself.
Here was a pride.
And this is the privacy info.
Also, if you were to write it down, take a look
You will rarely see you like this.
Moseley, a private institute
Tell me along with it, I have no idea
But tutorials are very few
And you will see that there are so many of them.
Here we have the command
Now, I need to know about this a bit more.
I just created it recently
College Management
If I create tables tomorrow
Inside him
Araite, inside the Biseculi database
And this series is our college management system project.
Database-driven
I need that one.
So how did we write it here
Hyphen C, look here
We have already handled the task.
It's not that desperate yet.
But now we need to look at this here
I'm leaving here.
Backslash C
And press harder
No, not that.
College Under Management
If you take all our wealth for your own gain, then in the end, it will be for the sake of Isaya, and we will go to the post-life realm of the soul.
I am running in the jungle.
So I thought, even so, if someone asks you tomorrow about today
Because in CLI, how can you determine the currently active database?
How can you create this database?
Or if you want to show the List of Databases
So how can you show it now?
Because when you run the GUI for it
Password for user, whatever is correct
I have already created this AC; please remove it.
Here, check the server
When you click
There's no need to do anything here.
I'm doing it here.
So, right now, this is coming to me
Create Database
And if I walk here
Create Database and I will get it
Here I write it down
Testing, owner, my postcrass will remain
CrateDB Testing
With the owner, yeah
The format will remain as is.
Local provider, Gangshan Limit, whatever it is
Write it so clearly that even I can understand it.
Your database has been created.
CrateDB Testing
Once someone performs a database operation
And look at this
Today we have a test.
I mean, both are connected.
You'll appear on both sides, whether you do it this way or that way.
With this provider,
If you wanted to delete and had使用的, there would be a drop there.
Olt, Kurt, and De Garbidi have been there
I'll drop it, drop it, let's go
It's gone, that's so easy
And you'll have to drop by for him.
You don't want to see the ones who are inside a database, and outside another database, you want to delete them.
You can do it.
No doubt. We can do it since then.
But even so, I'll have to tell you right here.
You will have to explain that you are the one who is doing this button.
And truly, you are a worthy one.
Is it a database?
Or is it a table?
Or is it a schema?
You mean, we'll have to explain what this thing is here, okay?
So, let's view it, you take a drop.
And, as for the Baidave, you can also write drop statements, and then you have your database.
Here, you can write database, database, and even thoughts on the database.
Vangar comes once a year when the Jokal Tech database triggers.
I feel like they're talking about me here.
Do a task
If I am here at test1
I am working.
Let me close this then.
I did it here in this way
Now drop
database
And that's your test1
drop database
My work is done, it's done, it's done.
Sometimes I've been noticing this
When you write even in lowercase, don't you?
In this way, you'll handle your database work efficiently.
Now I'm closing this.
Because going with CLI was a bit tricky
You'll have to write more code
And these days, all I do is curse PGAdmin 4.
So now we see
Our table creation
This is also way too simple.
Look, when you used to create the table
Some terms you need to understand
And that's first your table itself
then we have a column and then
Field, I already told you, we have a row
record, and then we have a primary key
It's basically when we completely understand the relationship
Understood, your primary key
whenever there are foreign keys, then we
You'll see it clearly enough, but what is a table?
What is a column field, what is a row, just a little bit
It's essential to understand, what exactly is a table?
It's a structured container.
inside your database
holding data about one
specific entity
like a student or course or department
We college management
system This is the one that
database is there, we
as our main
Our project, which moves forward like a project
the database of the college management system
It needs to be created perfectly.
So there, when we tables
When we talk about it, what is the table doing with the data?
stores it in an organized way, but
for a specific entity, green
we have multiple tables and green table
data of a specific entity
stores it and keeps it, when
We are the college management system
When we talk about it, in college we go there, students
We remember, students are special in their own way.
The table should be, we have professors
We have a department, we have
Your
courses
There are эксперт many, why isn't Vilār Pārthā here yet?
I'm not coming, but there will be many like this.
So, a table is created for all of them.
And when we create tables
Let's talk, so there we have something
called column and we have something called
record, isn't it, rows
and column, or field
And record, then what is field?
does, a vertical category
Yeah, and
that define what kind of data
is stored, basically column what
It speaks, representing the data
What type of data are you looking for here?
You're going to store it, like name
So when we created the column named, then me
You know that name is a string, and people
What is a row, horizontal
entry
in a table, each row
represents one complete distinct item
like one specific student's full profile
I already told you earlier today, when we
Speaking of rows, they will tell you
A related data represents it
Yes, this is a student, his related
data is the student's name, his
email, his date of birth, his course
Whoever it is, that's him.
Right, and then the primary key that makes it
unique
identifier for each row in a table
If you are talking to any student
If access is required, we need a unique identifier.
and that's your primary key, next we'll go a bit further
And we'll take a closer look inside deep, and
This is how we can create tables
in our PostgreSQL
and this is your syntax
By the way, so table if
If you need to create it, how can you do it? Look here.
create a table, table
Name, column name, and then we
have a data type, and after the data type we have a constraint
Also, the column to name
if you want to drop a table, data type
So I told you, simply
use the drop keyword, and then
Whatever your table name is, but
In between, you'll have to tell me, whether that
It's a database; is it a table?
If it's a schema, then in the middle it will be like this way
to write remains, and this
Look here, what did I tell you?
Bro, if you're here
show all the tables
tables in the current database
session, then dt
select star from table,
It was also known by the name of this database.
Big one, whatever it is, show tables, here a little bit in this manner
Yes, okay, in this manner
I have to write it here, okay, so
One sec, I've uninstalled PGAdmin4.
I'll open this big one.
And there's something here,
Okay, there are some things.
best practices, let's go, very good, let's do this
We'll take a quick look here, the comma here
Your last column is here,
You don't need to give them a comma there,
Simple, you'll find out soon.
And then look here, singular
Years, plural, meaning it's saying this
if you, the database you
Created it, okay, we're the ones who'll make it
Inside it, your users, your departments,
Your courses, your address, and what else
They will come, whatever tables there are
It will be called, if you take the first one
Made it singular, simple user
So the rebel, his course, departments,
Keep it that way, singular, everything.
If you've already made it plural, like added an 's'.
multiple, many
Courses, departments,
You have to do it this way,
Full Table Name,
As users,
Courses, okay
I gave the car to the garden.
The fact is that we all know
Any grudge in a car
You are being chased.
I mean, Varakar,
So you know that
You have been given a four-number.
It's already 20 o'clock.
So where are you at
You can give 20 characters
Empty memory
So why 255 there?
Extra space waste
Memory of
Time is just what it is; you'll find out here anyway.
But getting tired of respecting these things
You got it.
the semi-column you have
It should be.
Grab it, whatever your table name is
Whatever name you create for the database, make it in this case.
Keep it here, in this case, it's fine.
Leave it be and let's go; we'll talk plenty later.
There was a lot to talk about.
then we have a schema
and then we have a public folder
and inside a public folder we have
a table
We have a table over here.
I have to go through this heavy rain this time.
I'll explain why this is so in tomorrow's video.
Right click
Create
and then table
In this way, your table will now be created, correct?
One way is this.
to create a table
I'm leaving this here.
The second method is this.
You can see it at the top
We have a query tool here.
What we have here is a query tool.
Check out this query tool
What should I do about this? I'll click.
Now my query tool has arrived here.
I mean, I can write like Sela.
You'll find out if it doesn't highlight
It's not highlighted; there's a spelling mistake.
Now it's perfectly balanced, this is beauty.
Alright, and these are your users
So you need to put parentheses here
Not calibrations, and here a comma is required
So, you already follow these best practices.
Alright, and
Simple, what you need to do here now
First of all, the ID will seem to you
and in MySQL we have an int
Over here, we have a serial.
so we have a serial, meaning here
One, two, three, it will proceed forward series-wise
We'll assign it to primary.
primary, one second, primary
and here you are
If you need to give a comma, then once this is done for you
then go there and do this
You can give me a name, can't you?
Guys, keep the variable character
Don't worry, in tomorrow's video we'll go even further
We will thoroughly understand the entire data type, but one variable character is there.
Let's go with 100.
not semicolon
but a comma, then email
and you have to write
where care, okay
Here you go; I don't trust email.
and
He is active; he is not inactive.
basically, the users here are the ones
All of it-progress will come from within me, yours
students, your professors
even your admin
So we are making this role-based unified, we are doing some
So let's say it: don't worry, we'll go deeper into it later.
But it's the same users, right?
We're all going to tackle it, okay?
We'll just leave it here, so
is underscore, now blow
Alright, now look here, this is yours
Last
What is field, isn't it
When I am creating a table, this is my
last property and here you are
Do not use a comma whenever
You're creating this, so here it is
A semicolon is mandatory in this way
Alright, now here you are, this one
Selecting, what you are seeing now, execute
Script, you can do this.
or else you'll go there yourself
You can press F5.
But let's go ahead, I'll just click it.
So create a table,
Query returned successfully in 86
milliseconds, my turn is ready now,
Now support me
Looking here, brother, one second,
Here it is
dt, so all tables in the current database
So if I write dt here,
I write dt, okay,
and let's go, if I
Select, check this out, guys,
This won't work here, because this is CLI.
It's a bit short, isn't it? This CLI is a bit short,
This, I mean, right here
Because you're inside the PG admin, a little bit of you
like dt to paste this exact copy into the CLI
But he leaves anyway,
If you want to look here
Which tables, brother?
You have not yet entered inside this database
Create it, then again,
Here, it also has a bit of a different touch.
I'll tell you that too, right now.
So, guys, here's how it'll be—you'll have to write select
star from,
Now, think about this, you
What's going on, PG
tables, okay
and we need to go with
the WHERE clause,
where schema
name is
equal to your public,
Let's try.
Let's see what happens, okay.
Now you can see here,
Many people make this mistake here.
The same error is going to appear.
and that is the public column does not
exist, by the way, first
"double quotes" 'single quotes'
I write, your movement was mostly in MySQL
It's moving, but there's a problem here
This is, that when you are on double quotes
You're writing, listen carefully, when you
You're writing within double quotes, then
In PostgreSQL
Treated as an identifier
basically, like a column
Being treated, meaning, as if this
I have created the column: id, name,
This is one of my columns, right, so something like that
When you write a double quote, it feels like
that this is a public column,
which does not exist here
Anyway, he doesn't exist anywhere.
Yeah, well, he's the one saying it, isn't he?
column, public, does not exist, this
So instead of double quotes,
We need to use single quotes.
Seen this, if
I don't even bring that error with me, ever
Nothing comes to your mine either, but the
moment if I put single quotes around it,
Let's stay together, little one, there's no problem at all.
Now, if I run this, and
Boom, guys, see,
inside public, which is from my table
Philal is one and the same, and that's your users.
Look here, we've created a user called Filal.
That is it, so here it is
Whatever you may be
database, Philal I'm still here
I'm inside college management, aren't I, its
Inside, you know, let's say you're in college
Not management, you are inside some other database
Then, if you need to人脸识别 there as well
Which tables exist?
Here it is, you will type the same command as this
You've already understood that even there, it's from this start.
Yeah, I mean, all of it
Provide the data for the tables, otherwise, if you wish
So if you just type users, you'll get users
but from pg underscore table you
I mean whatever your current
all the tables for the database
records that are adding this, meaning data about data
and also holds the data of tables
Keeping it, the data table as well
and schema name public, therefore writing this because
inside the schema
we have a public, then inside it we have
this table, then that's why, this command
So, this is how you create a table
And this is how you can check, Okay
and I think here I am
There is no need to say it so loudly.
What does this command do, table
you are creating this is what
The name of your table, what is this
Your column's name is
Field name, this is
Your type, data type, and this is
your constraint
name, data type
Data type is your field
and here we are not using a comma, here
using a semicolon here and snake case
We are using it; this is your plural.
If I am, then in this way
You table
you can create it, if you want, you can now do it
You can also drop it, it's simple
drop table
and then we have users
If you write this and then this
If you run it, your table will also
It's dropped; now if I run it again
So now there is no more table.
Thus, in this way we have seen
How to create a database and then
How to create tables, okay
So now, guys, here's a task.
For you, the task is for you guys, and that is
simple, create this
Look here, create the
I'll write the courses table
Let's create a courses table
with an ID, title
and fee, now this fee
It will be a data type, that will be this
10.2 this 8.2
Alright, think about it—why would I have written this?
But this one, now you have to create it
inside your college
management database, simple
Inside it, you will find courses
I need to create a table inside which simply
This will be a thin fill with proper
data type and make one of them your primary key
and whatever code you write
Just paste it in the comment section
I will understand that your homework has been done.
So this is your task.
If only you could do this much
So, you understand that you've learned so much already
That's all for today's video
I hope you'll like the video very much.
If anyone's yet
PGAdmin or PostgreSQL properly
Please comment
I will definitely help.
Today was the third day
We have already seen the database and tables as well.
Tomorrow we will understand data types
And a few important terms
DDL, schemas, tables, what all
DDM is also here
You won't get much out of it anyway.
How did the video like? Please definitely let me know. Also, make sure to complete the task I gave you.
Please like the video; we're aiming for 500 likes.
If you haven't subscribed to my channel yet, please do so now.
See you in the next video
The gas tank is so full
Took it