Prin utilizarea acestui site, sunteți de acord cu Politica de confidențialitate.
Accepta
EnterineEnterineEnterine
  • ACASĂ
  • Pro
  • Tehnologie
  • Microsoft
    • Azur
    • ConfigMgr/SCCM
    • Dpm
    • Orchestrator
    • Hyper-V
    • Microsoft Edge Insider
    • MSI
    • Birou 365
    • Office Insider
    • Putere bi
    • Skype
    • Server SQL
    • Echipe
  • Ferestre
    • Centrul de administrare Windows
    • Client Windows
    • Windows Server
  • Lista de colecție de interogări SCCM
Lectură: PostgreSQL DROP Database
Redimensionare fontAa
EnterineEnterine
Redimensionare fontAa
  • ACASĂ
  • Pro
  • Tehnologie
  • Microsoft
  • Ferestre
  • Lista de colecție de interogări SCCM
Căutare
  • ACASĂ
  • Pro
  • Tehnologie
  • Microsoft
    • Azur
    • ConfigMgr/SCCM
    • Dpm
    • Orchestrator
    • Hyper-V
    • Microsoft Edge Insider
    • MSI
    • Birou 365
    • Office Insider
    • Putere bi
    • Skype
    • Server SQL
    • Echipe
  • Ferestre
    • Centrul de administrare Windows
    • Client Windows
    • Windows Server
  • Lista de colecție de interogări SCCM
PostgreSQL

PostgreSQL DROP Database

Publicat: February 18, 2024
4 Min Citește
Cota

PostgreSQL DROP Database.

Cuprins
Using DROP DATABASESyntaxParametersExampleUsing dropdb CommandSyntaxParametersOptionsExample

Using DROP DATABASE

This command drops a database. It removes the catalog entries for the database and deletes the directory containing the data. It can only be executed by the database owner. This command cannot be executed while you or anyone else is connected to the target database (connect to Postgres or any other database to issue this command).

Syntax

The syntax for DROP DATABASE is given below −

DROP DATABASE [ IF EXISTS ] <name>

Parameters

The table lists the parameters with their descriptions.

S. Nu.Parameter & Description
1IF EXISTSDo not throw an error if the database does not exist. A notice is issued in this case.
2nameThe name of the database to remove.

We cannot drop a database that has any open connections, including our own connection from psql or pgAdmin III. We must switch to another database or template1 if we want to delete the database we are currently connected to. Thus, it might be more convenient to use the program dropdb instead, which is a wrapper around this command.

Example

The following is a simple example, which will delete testdb from your PostgreSQL schema −

DROP DATABASE testdb;

Using dropdb Command

PostgresSQL command line executable dropdb is a command-line wrapper around the SQL command DROP DATABASE. There is no effective difference between dropping databases via this utility and via other methods for accessing the server. dropdb destroys an existing PostgreSQL database. The user, who executes this command must be a database super user or the owner of the database.

Syntax

The syntax for dropdb is as shown below −

dropdb  [option...] <dbname>

Parameters

The following table lists the parameters with their descriptions

S. Nu.Parameter & Description
1dbnameThe name of a database to be deleted.
2optioncommand-line arguments, which dropdb accepts.

Options

The following table lists the command-line arguments dropdb accepts −

S. Nu.Option & Description
1-eShows the commands being sent to the server.
2-iIssues a verification prompt before doing anything destructive.
3-VPrint the dropdb version and exit.
4–if-existsDo not throw an error if the database does not exist. A notice is issued in this case.
5–helpShow help about dropdb command-line arguments, and exit.
6-h hostSpecifies the host name of the machine on which the server is running.
7-p portSpecifies the TCP port or the local UNIX domain socket file extension on which the server is listening for connections.
8-U usernameUser name to connect as.
9-wNever issue a password prompt.
10-WForce dropdb to prompt for a password before connecting to a database.
11–maintenance-db=dbnameSpecifies the name of the database to connect to in order to drop the target database.

Example

The following example demonstrates deleting a database from OS command prompt −

dropdb -h localhost -p 5432 -U postgress testdb
Password for user postgress: ****

The above command drops the database testdb. Here, I have used the postgres (found under the pg_roles of template1) username to drop the database.

Etichetat:databasedbPostgresqlpsql
Articolul precedent L1 L2 L3 What’s the Difference
Articolul următor Office Insider 2206 for Windows
Lasă un comentariu Lasă un comentariu

Lasă un răspuns Anulează răspunsul

Adresa ta de e-mail nu va fi publicată. Câmpurile obligatorii sunt marcate *

Acest site folosește Akismet pentru a reduce spamul. Aflați cum sunt procesate datele comentariilor dvs.

Traducere

English中文(简体)DanskNederlandsFrançaisDeutschItaliano한국어PolskiPortuguêsRomânăEspañolУкраїнська
de Transposh - translation plugin for wordpress

Postări populare

Cerințe de sistem pentru Windows Server 2016
Windows Server
Lista de colecție de interogări din Configuration Manager
Lista de colecție de interogări din Configuration Manager
Configmgr
Navigarea structurată/gestionată este activată în paginile moderne din site-urile clasice ale echipelor
Teh
SCCM nu s-a obținut locațiile DP ca versiune așteptată de la MP
Configmgr

Postări recente

Instalarea și configurarea Fail2ban pentru protecție SSH pe Ubuntu 24.04
Linux
Activarea și configurarea FirewallD pe AlmaLinux
Linux
Crearea utilizatorilor și configurarea cheii SSH în AlmaLinux
Linux
Cum să resetați parola pe AlmaLinux
Linux

© 2023 Enterine

Accesați versiunea mobilă
Bine ai revenit!

Conectați-vă la contul dvs

Nume de utilizator sau adresă de e-mail
Parolă

Ți-ai pierdut parola?