Postgres Postgresql Downloads
Postgres Postgresql Downloads
SELECT version( );
Host : localhost
Port : 5432
Maintenance database : postgres
Password : 123456
Image..
SELECT version( );
\l;
\c db_name;
- Droping a database
a. We are going to learn how to drop or delete
the database which we don’t need anymore in
PostgreSQL
b. The drop / delete command is used to
eternally delete all the file entries and data
directories from the PostgreSQL platform
c. Therefore, we have to use this command very
carefully.
d. In PostgreSQL, we can drop the database in
two ways :
1. Drop database PgAdmin
2. Drop database using SQL shell
(Command Line)
e. Drop database using PgAdmin
1. Step 1 : firstly, we will open the pgAdmin
in our local system
2. Step 2 : select the database by a left –
click on it
3. Step 3 : then right – click on the database
then clik on delete / drop option from the
given drop – down list to delete the
database
4. Step 4 : database will be deleted
immediately from the record
f. Drop database using SQL shell (Command
Line)
We’re going to drop the database in the SQL
shell. The syntax for dropping the database
is :
\l
SELECT
pg_terminate_backend(pg_stat_activity.pi
d)
FROM pg_stat_activity
WHERE pg_stat_activity.datname =
“db_name”;
g. dropdb
a) In PostgreSQL, the dropdb is a command
– line executable command which covers
the SQL drop database command
b) This command can only be run by those
end – users who are the owner of the
database or a database superuser
c) We can remove the database remotely
with the help of the dropdb statement
d) The syntax for dropdb command is,
e) Example
Options Description
-e Here e means Echo, which is used to create
and send to the server
-i It is used to show the verification prompt
before operating any fatal job
--help It allows us the help with dropdb
command-line statements
-h host It define the names of the host of the
system, where the server is directly
executing
-p port This option defines the Unix domain socket
file extension, where the server is creating
the connections
-v We can use -v option, to print the dropdb
version
-U username It is used to display the user name
-w If we don’t need a password screen, we can
use the option
Maintenance To connect the database for dropping the
dp-=dbname target database, we will use this option to
describe the database name
--if exists This option will display an error rather than
a warning if the database does not exist
-w This option is used to prompt for a
password before dropping the database