SQL Drop Database

SQL Drop数据库

When we work with the database there are very rare cases when we want to drop the complete database. However, sometimes it’s required to do a complete cleanup and fresh database setup.

当我们使用数据库时,在极少数情况下我们要删除整个数据库。 但是,有时需要进行完整的清理和全新的数据库设置。

The meaning of dropping a database is that all the tables in the database will be deleted along with the data that is stored in the table.

删除数据库的意思是将删除数据库中的所有表以及表中存储的数据。

Now we will learn how to drop the database for the below-mentioned databases.

现在我们将学习如何删除下面提到的数据库的数据库。

  1. MySQL Drop DatabaseMySQL Drop数据库
  2. PostgreSQL Drop DatabasePostgreSQL Drop数据库
  3. SQL Server Drop DatabaseSQL Server删除数据库

We will go in detail for all the above mentioned DBs.

我们将详细介绍上述所有数据库。

MySQL Drop数据库 (MySQL Drop Database)

We will now try to understand how to drop a database in MySQL.

现在,我们将尝试了解如何在MySQL中删除数据库。

Please note that the below-mentioned script should be run on MySQL shell prompt.

请注意,下面提到的脚本应在MySQL Shell提示符下运行。

Drop Database Syntax: –

删除数据库语法:–

DROP DATABASE [IF EXISTS] database_name;

It is important to add the IF EXISTS clause as MYSQL will give an error if we try to drop a database that does not exist.

添加IF EXISTS子句很重要,因为如果我们尝试删除不存在的数据库,则MYSQL将给出错误。

Example for Drop Database: –

删除数据库示例:–

DROP DATABASE IF EXISTS TestDB;

The above query will drop the database with the name as TestDB.

上面的查询将删除名称为TestDB的数据库。

PostgreSQL Drop数据库 (PostgreSQL Drop Database)

Assume that the database that we want to drop is TestDB.

假设我们要删除的数据库是TestDB

The drop database command can only be executed by the user having owner permission on the TestDB.

drop database命令只能由对TestDB具有所有者权限的用户执行。

Also, it is always better to test the connection to the database. Before executing the drop command it is good to make sure that the database is not connected.

同样,最好测试与数据库的连接。 在执行drop命令之前,最好确保未连接数据库。

Connecting to another database will ensure that the connection is disconnected from the target database.

连接到另一个数据库将确保连接与目标数据库断开连接。

Let us now try to drop TestDB.

现在让我们尝试删除TestDB

  1. Right-Click on the database and click on Delete/Drop option.右键单击数据库,然后单击“删除/删除”选项。
  2. Drop database confirmation screen will appear.出现删除数据库确认屏幕。
  3. Click on OK and the database will get dropped.单击确定,数据库将被删除。

PostgreSQL Right Click Drop

PostgreSQL右键单击拖放

PostgreSQL Drop Confirmation

PostgreSQL删除确认

TestDB is successfully dropped.

TestDB已成功删除。

Please find below the script that can be used as an alternative to the UI.

请在下面找到可以替代UI的脚本。

dropdb -p 5000 -h admin -i -e demo

To destroy the database demo using the server on host admin, port 5000.

要使用主机admin端口5000上的服务器销毁数据库演示

It is useful to use the dropdb program from PostgreSQL which is a wrapper around drop database command.

使用PostgreSQLdropdb程序很有用,它是drop database命令的包装器。

SQL Server删除数据库 (SQL Server Drop Database)

We will not try to use DROP command to drop a database in SQL server.

我们不会尝试使用DROP命令在SQL Server中删除数据库。

The following steps need to be followed to drop a database in SQL Server.

要在SQL Server中删除数据库,需要遵循以下步骤。

  1. Launch SQLServer Management Studio and authenticate to log in.启动SQLServer Management Studio并进行身份验证以登录。
  2. In the Object Explorer, select the database that you want to drop. We will be selecting TestDB for our purpose. Right click and click on delete.在对象资源管理器中,选择要删除的数据库。 我们将根据目的选择TestDB。 右键单击,然后单击删除。
  3. A pop-up screen will appear. Click on OK and the database will get dropped.将会出现一个弹出屏幕。 单击确定,数据库将被删除。

SQLServer Right Click Drop

SQLServer右键单击拖放

SQLServer Drop Screen

SQLServer拖放屏幕

TestDB is dropped successfully.

TestDB成功删除。

翻译自: https://www.journaldev.com/24489/sql-drop-database-mysql-postgresql-sql-server

SQL Drop数据库– MySQL,PostgreSQL,SQL Server相关推荐

  1. 视图的重命名mysql语句_sql语句重命名字段-视图重命名sql语句-数据库重命名sql语句...

    sql语句如何重命名表名和列名? 一.更改数据库名 sp_renamedb 更改数据库的名称. 语法: sp_renamedb [ @dbname = ] ' old_name ' , [ @newn ...

  2. mysql转储导入错误_数据库MYSQL导入SQL文件时错误的解决方法(2种)

    从服务器数据库用navicate导出的.sql文件后再用navicate导入到本地的数据库中会出现若干条记录的错误: [Err] 1064 – You have an error in your SQ ...

  3. sql查看数据库线程数_SQL Server始终在可用性组数据库上的最大辅助线程

    sql查看数据库线程数 This article gives an overview of the Max Worker Threads for the SQL Server Always On Av ...

  4. mysql执行sql文件创建数据库_mysql执行sql文件创建数据库

    如何执行一个mysql的sql脚本文件 sql脚本是包含一到多个sql命令的sql语句,我们可以将这些sql脚本放在一个文本文件中(我们称之为"sql脚本文件"),然后通过相关的命 ...

  5. 创建数据库mysql的sql语句是_创建数据库和表的SQL语句

    SQL常用语句: CREATE DATABASE 库名;创建数据库 DROP DATABASE库名: 删除数据库 USE 库名; (1) 数据记录筛选: sql="select * from ...

  6. [数据库]---mysql 插入sql之 INSERT INTO和INSERT IGNORE INTO和REPLACE INTO和ON DUPLICATE KEY UPDATE比较应用

    mysql插入一条数据方式有四种,接下来逐个说明验证: 前提: 有一个表,作为本次测试: CREATE TABLE `zs_test` (`id` int(11) NOT NULL AUTO_INCR ...

  7. 软件测试--------数据库MySQL 常用sql语句

    1 --选择:    select * from table1 where 范围 2 --插入:       insert into table1(field1,field2) values(valu ...

  8. 什么是腾讯云关系型数据库(MySQL/SQL Server/MariaDB/PostgreSQL详解)

    什么是腾讯云关系型数据库?腾讯云关系型数据库提供 MySQL.SQL Server.MariaDB.PostgreSQL详细介绍.腾讯云关系型数据库让您在云中轻松部署.管理和扩展的关系型数据库,提供安 ...

  9. 驰网云数据库MySQL SQL Server

    驰网云数据库MySQL &SQL Server 在最近几年,云数据库逐渐成为焦点中的焦点.根据IDC数据显示,到2025年,全球超过50%的数据库将部署在公有云上:在中国市场,这个数据将达70 ...

最新文章

  1. Linux环境编程--文件基本操作
  2. 刷题练习记录(3)——无重复字符的最长子串(JAVA 和 Python)——set()函数/集合...
  3. __slots__的作用
  4. antiddos翻译_AntiDDoS8000系列DDoS防御系统
  5. 年后跳槽必备的 Java 题库,全网最全!
  6. Python使用yagmail库实现发送邮件功能
  7. 互联网产品哪个不火哪个就在红利期
  8. sql优化基数和耗费_基数估计在SQL Server优化过程中的位置
  9. 傅立叶:你让我如何理解你?
  10. springboot mybatis 后台框架平台 集成代码生成器 shiro 权限
  11. 使用STM32固件库开发GD32 汇总
  12. linux抓包UDP流量
  13. 2021爱分析·时尚品牌数字化厂商全景报告
  14. FPGA之三八译码器
  15. swb-2润湿平衡测试仪_自动化测试
  16. 4款良心电脑软件,有两款虽已停更,依然支持免费使用
  17. stm8L ADC多通通DMA采集和EEPROM一起使用解决死机和数据错位问题——寄存器
  18. ts中类型检测的鸭子类型是什么意思
  19. java狐妖外传,月华凌乱——狐不归外传
  20. WEB网站类型系统中使用的OFFICE控件

热门文章

  1. JAVA 内存泄露的理解
  2. chm文件的中文显示乱码问题解决
  3. [转载] 七龙珠第一部——第005话 邪恶沙漠的雅木茶
  4. Guacamole-HTML5无客户端远程桌面
  5. 如何在网页中每小时更新一次数据?
  6. [转载] Python之使用K-Means算法聚类消费行为特征数据分析(异常点检测)
  7. [转载] 整理总结 python 中时间日期类数据处理与类型转换(含 pandas)
  8. MVC+WebApi+Restful
  9. 洛谷 题解 P2117 【小Z的矩阵】
  10. 27_线程池_线程池实现原理