当前位置: 首页 > news >正文

【PostgreSQL】从零开始:(十一)PostgreSQL-Dropdb命令删除数据库

 dropdb命令删除数据库

命令

[postgres@postgre-sql bin]$ dropdb --help
dropdb removes a PostgreSQL database.Usage:dropdb [OPTION]... DBNAMEOptions:-e, --echo                show the commands being sent to the server-f, --force               try to terminate other connections before dropping-i, --interactive         prompt before deleting anything-V, --version             output version information, then exit--if-exists               don't report error if database doesn't exist-?, --help                show this help, then exitConnection options:-h, --host=HOSTNAME       database server host or socket directory-p, --port=PORT           database server port-U, --username=USERNAME   user name to connect as-w, --no-password         never prompt for password-W, --password            force password prompt--maintenance-db=DBNAME   alternate maintenance databaseReport bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>
[postgres@postgre-sql bin]$ 

参数

参数说明
-e, --echo显示发送到服务端的命令
-f, --force尝试在删除之前终止其他连接
-i, --interactive在删除任何内容之前提示
-V, --version查看版本信息
--if-exists如果数据库不存在,不要报告错误
-?, --help查看帮助并退出
-h, --host=HOSTNAME指定数据库编码或IP
-p, --port=PORT数据库服务器端口号
-U, --username=USERNAME连接的用户名
-w, --no-password永远不提示输入口令
-W, --password强制提示输入口令
--maintenance-db=DBNAME备用维护数据库

例子

查看数据库列表

postgres=# \lList of databasesName        |   Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | ICU Locale | ICU Rules |   Access privileges   
--------------------+-----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------ci_database_test01 | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | ci_database_test02 | postgres  | EUC_TW   | libc            | C           | C           |            |           | ci_database_test03 | circledba | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | circledba_test     | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | postgres           | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | template0          | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +|           |          |                 |             |             |            |           | postgres=CTc/postgrestemplate1          | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +|           |          |                 |             |             |            |           | postgres=CTc/postgres
(7 rows)postgres=# 

使用dropdb删除ci_database_test02数据库

[postgres@postgre-sql bin]$ ./dropdb -h 127.0.0.1 -p5432 -U postgres ci_database_test02
Password: 
[postgres@postgre-sql bin]$ 

再次查看数据库列表

postgres=# \lList of databasesName        |   Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | ICU Locale | ICU Rules |   Access privileges   
--------------------+-----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------ci_database_test01 | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | ci_database_test03 | circledba | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | circledba_test     | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | postgres           | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | template0          | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +|           |          |                 |             |             |            |           | postgres=CTc/postgrestemplate1          | postgres  | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +|           |          |                 |             |             |            |           | postgres=CTc/postgres
(6 rows)postgres=# 

我们已经删除成功了

http://www.lryc.cn/news/262314.html

相关文章:

  • UDP网络编程其他相关事项
  • Redhat LINUX 9.3 + PG 16.1 搭建主备流复制
  • kafka设置消费者组
  • Worker-Thread设计模式
  • npm 安装包遇到问题的常用脚本(RequestError: socket hang up)
  • 活动 | Mint Blockchain 将于 2024 年 1 月 10 号启动 MintPass 限时铸造活动
  • Android动画(四)——属性动画ValueAnimator的妙用
  • C语言飞机大战
  • js 原型 和 原型链
  • 如何利用SD-WAN节省运维成本和简化运维工作?
  • 在工作中使用CHAT提高效率
  • Maven 项目的三种打包方式与 pom.xml 文件中项目描述
  • 【普中】基于51单片机简易计算器数码管显示设计( proteus仿真+程序+实物演示+讲解视频)
  • 【Android】DeepLink
  • 微服务Redis-Session共享登录状态
  • 30道C++ 基础高频题整理(附答案背诵版)
  • 【Spark面试】Spark面试题答案
  • Axure的动态面板
  • 【STM32】STM32学习笔记-对射式红外传感器计次 旋转编码器计次(12)
  • 后端项目操作数据库-中枢组件Service调用Mapper实现增删改查-实例
  • kafka学习笔记--节点的服役与退役
  • 2023-12-16:用go语言,给定整数数组arr,求删除任一元素后, 新数组中长度为k的子数组累加和的最大值。 来自字节。
  • libxls - 编译
  • 自建私有git进行项目发布
  • 华为HCIP认证H12-821题库上
  • Web安全漏洞分析—文件包含
  • C++入门【9-C++循环】
  • Python3 数字(Number) ----20231215
  • PyQt6 QToolBar工具栏控件
  • nodejs+vue+微信小程序+python+PHP基于大数据的银行信用卡用户的数仓系统的设计与实现-计算机毕业设计推荐