DROP DATABASE command in SQL

How is a database drop used in SQL? This article will guide you in detail on how to delete a database in SQL.

How is a database drop used in SQL ? This article will guide you in detail on how to delete a database in SQL .

 

The DROP DATABASE statement in SQL is a crucial command used to permanently delete a database from a Database Management System (DBMS). When executed, this command deletes the database and all associated objects, including tables, views, stored procedures, and other entities.

 

What is DROP DATABASE in SQL?

The DROP DATABASE command in SQL is used to completely delete a database and all its objects, such as tables, indexes, views, and other dependent objects. Once executed, this operation cannot be undone, so it is important to back up the database before deleting it.

This command is commonly used when a database is no longer needed or needs to be deleted for reorganization. Before running the command, ensure you have sufficient privileges to delete the database, as typically only administrators have the necessary permissions.

  • Purpose: To permanently delete a database from the DBMS.
  • Result: All database data, schemas, and objects are deleted.

Syntax of the DROP DATABASE command in SQL

DROP DATABASE ten_co_so_du_lieu;

The database_name is always unique in an RDBMS. Learn more about RDBMS in SQL .

Example of a DROP DATABASE command in SQL

 

If you want to delete an existing database, for example named TipsMake , the DROP DATABASE command would be written as follows:

DROP DATABASE TipsMake.com;

Note: Please be careful when performing this action, as deleting an existing database may completely erase all information stored within it.

Make sure you have administrator privileges before deleting any databases. Once a database is deleted, you can check the database list again using the command SHOW DATABASES;below:

SQL> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | CONGNGHE | | LANGCONGNGHE | | WINDOWS | | mysql | | ANDROID | | iOS | +--------------------+ 6 rows in set (0.00 sec)

The DROP DATABASE command is quite simple, isn't it? In the next lesson, we'll learn about the USE command, used to select a database.

Key points to remember about the SQL DROP DATABASE statement

  • Deleting a database: Deleting a database is a permanent action and will result in the loss of all information stored in the database.
  • Backup: It's always a good practice to back up your database before performing any deletion operations on it.
  • Permissions: Ensure you have the necessary permissions to delete the database. Typically, administrators can delete databases.
  • Database state: A database can be deleted regardless of its state: offline, read-only, doubtful, etc.
  • Database snapshot: Deleting a database snapshot will remove the database snapshot from the SQL Server instance and delete the sparse files of the physical NTFS file system that were snapshotted.
  • Copying: To delete a database that has been published for transactional replication, or that has been published or registered for merge replication, you must first delete the copy from the database.
  • System database: Users cannot directly delete or edit the system database.
Related posts
  • Basic SQL syntax

    sql has a set of rules and instructions called syntax (syntax). this article will quickly list for you the basic sql syntax.
Other SQL articles
  • Learn about the most popular RDBMSs

    rdbms có nhiều loại như mysql, oracle, sql server, mongo db, sybase,... Để hiểu hơn về rdbms, trong bài viết này chúng ta sẽ tìm hiểu về một số rdbms phổ biến nhất, so sánh tính năng cơ bản của chúng. mời các bạn cùng theo dõi.
  • Window Functions in SQL: Everything you need to know

    window function trong sql là gì? hãy cùng nhau khám phá cách dùng các window function để tiến hành phân tích thống kê chỉ bằng một truy vấn sql.
  • DROP TABLE or DELETE TABLE command in SQL

    xóa bảng trong sql được sử dụng khá nhiều. thuật ngữ này còn được gọi là drop table trong sql. dưới đây là mọi điều bạn cần biết về xóa table trong sql.
  • CREATE TABLE command in SQL to create a database table

    lệnh create table trong sql có tác dụng gì? Ở bài viết này, hãy cùng nhau tìm hiểu mọi điều bạn cần biết về câu lệnh create table trong sql nhé!
  • Expressions in SQL

    một biểu thức là sự kết hợp của một hoặc nhiều giá trị, toán tử và hàm sql để đánh giá 1 giá trị. những biểu thức sql này giống như công thức và chúng được viết bằng ngôn ngữ truy vấn.
  • Basic SQL syntax

    sql có một tập hợp quy tắc và hướng dẫn được gọi là syntax (cú pháp). bài này sẽ liệt kê nhanh cho bạn những cú pháp sql cơ bản.
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup