PL-SQL
Oracle PL/SQL FOR LOOP with Example
What is For Loop? "FOR LOOP" statement is best suitable when you want to execute a code for a...
The DROP DATABASE statement removes all the catalog entries and data directory permanently from the PostgreSQL environment. So, you should be extra cautious when performing this operation.
However, this command can be executed only by the database owner. You also can't execute this command while someone is connected with the target database. You need to connect to some other database to execute the DROP DATABASE command.
Syntax:
DROP DATABASE [IF EXISTS) name;
Here:-
Let's see it in action
Step 1) Use command \l to determine the currently available database.
Step 2) To drop database enter command
drop database gtupapers
Use command \l to check whether DB is deleted
Step 3) Try to drop the same database again, you will get an error.
Step 4) Drop the database with IF exists clause and you get a warning
drop database IF EXISTS gtupapers
Step 1) Right Click on database "gtupapers" and click "Delete/Drop."
Step 2) Click OK on the confirmation pop-up
Database is deleted.
The dropdb command allows you to delete database remotely. But, the user must be the owner of the database in order to delete that database.
Syntax:
Dropdb [option.] dbname
Option | Description |
-e | Echo commands that dropdb creates and sends to the server. |
-i | Display a verification prompt before performing any destructive job |
-V | Use this option to print the dropdb version. |
--help | Provide help with dropdb command-line arguments. |
-h host | Helps you to specify the name of the host of the system on which the server is currently running. |
-p port | Option allows you to specify the Unix domain socket file extension on which the server is establishing connections. |
--if exists | If exists will show an error instead of a warming if the DB does not exit |
-U username | User name to connect as. |
-w | Use this option if you don't want a password prompt |
-W | Use this parameter to prompt for a password before dropping the database. |
maintenance db-=dbname | the database name of the to connect to drop the target database. |
We want to destroy a database gtupapers with the help of a server on host rome, port 4565, with verification and you need to use following command:
dropdb -p 4565 -h rome -i -e gtupapers
Database "gtupapers" will be permanently deleted.
Are you sure? (y/n) if you select y, then you can
DROP DATABASE gtupapers;
What is For Loop? "FOR LOOP" statement is best suitable when you want to execute a code for a...
In this tutorial, we will discuss the key difference between SQL and MySQL. Before discussing SQL...
What is a union? Unions combine the results from multiple SELECT queries into a consolidated...
In this SQL Query cheat sheet you will learn {loadposition table-of-content} What You Will Learn:...
What is Exception Handling in PL/SQL? An exception occurs when the PL/SQL engine encounters an...
What is Database Design? Database Design is a collection of processes that facilitate the...