mysql刪庫命令是啥 刪除資料庫的命令是什麼?

2021-10-18 22:03:06 字數 1331 閱讀 7595

刪除資料庫的命令是「delete data」,具體格式為「drop database [if exists] 資料庫名;」,可以刪除資料庫中的所有**並同時刪除資料庫。如果要使用「drop database」,需要獲得資料庫drop許可權。

當資料庫不再使用時應該將其刪除,以確保資料庫儲存空間中存放的是有效資料。刪除資料庫是將已經存在的資料庫從磁碟空間上清除,清除之後,資料庫中的所有資料也將一同被刪除。

在 mysql 中,當需要刪除已建立的資料庫時,可以使用 drop database 語句。其語法格式為:drop database [ if exists ] 資料庫名

語法說明如下:資料庫名:指定要刪除的資料庫名。

if exists:用於防止當資料庫不存在時發生錯誤。

drop database:刪除資料庫中的所有**並同時刪除資料庫。使用此語句時要非常小心,以免錯誤刪除。如果要使用 drop database,需要獲得資料庫 drop 許可權。注意:mysql 安裝後,系統會自動建立名為 information_schema 和 mysql 的兩個系統資料庫,系統資料庫存放一些和資料庫相關的資訊,如果刪除了這兩個資料庫,mysql 將不能正常工作。

示例:檢視資料庫mysql> show databases;

| database |

| information_schema |

| mysql |

| performance_schema |

| sakila |

| sys |

| test_db |

| test_db_char |

| test_db_del |

| world |

9 rows in set (0.00 sec)

使用命令列工具將資料庫 test_db_del 從資料庫列表中刪除mysql> drop database test_db_del;

query ok, 0 rows affected (0.57 sec)

mysql> show databases;

| database |

| information_schema |

| mysql |

| performance_schema |

| sakila |

| sys |

| test_db |

| test_db_char |

| world |

8 rows in set (0.00 sec)

此時資料庫 test_db_del 不存在。

Mysql是怎麼刪除資料的

重建表optimze table analyze table alter table這三種方式重建表的區別 mysql show variables like innodb file per table variable name value innodb file per table on 1ro...

MySQL刪除資料

mysql通過delete從表中刪除 去掉 資料。可以從表中刪除特定的行或者從表中刪除所有的行。下面語句是從customer表中刪除一行 delete from customers where cust id 10006 先檢視表customers在刪除前的成員 select cust id,cus...

MySQL 刪除資料

從資料表中刪除資料使用 delete 語句,delete 語句允許用 where 子句指定刪除條件。語法格式 delete from table name where table name 要執行刪除操作的表 where 為可選引數,用於指定刪除條件,如果沒有 where 子句,將刪除表中的所有記錄...