mysql資料庫建立 檢視 修改 刪除

2021-09-26 23:24:21 字數 923 閱讀 7953

一、建立資料庫

使用預設字符集

不指定字符集時,mysql使用默字符集,從mysql8.0開始,預設字符集改為utf8mb4,建立資料庫的命令為create database 資料庫名稱

#建立資料庫testdb,使用預設字符集

create database testdb;

使用指定的字符集建立資料庫,命令為create database 資料庫名稱 character set 字符集

#建立資料庫testdb,使用utf8字符集

create database testdb character set utf8;

二、檢視資料庫

mysql檢視資料庫的命令很簡單,就是show databases,會顯示當前所有的資料庫

三、修改資料庫

修改資料庫時可修改資料庫的字符集,命令為alter database 資料庫名 character set 字符集

#修改資料庫testdb的字符集為utf8

alter database testdb character set utf8;

四、刪除資料庫

刪除資料庫命令為drop database 資料庫名

#刪除名稱為testdb的資料庫

drop database testdb;

五、進入資料庫

​ 想要使用哪個資料庫,就使用use 資料庫名稱就行,比如我要使用testdb這個資料庫,我只需要執行命令use testdb;就可以了

mysql資料庫建立 檢視 修改 刪除

一 建立資料庫 使用預設字符集 不指定字符集時,mysql使用默字符集,從mysql8.0開始,預設字符集改為utf8mb4,建立資料庫的命令為create database 資料庫名稱。建立資料庫testdb,使用預設字符集 create database testdb 使用指定的字符集建立資料庫...

MySQL修改刪除 選擇資料庫

alter database 資料庫名 語法說明如下 alter database 用於更改資料庫的全域性特性。使用 alter database 需要獲得資料庫 alter 許可權。資料庫名稱可以忽略,此時語句對應於預設資料庫。character set 子句用於更改預設的資料庫字符集。刪除資料庫...

MySQL資料庫的查詢 建立 修改 刪除 使用

sql structured query language 結構化查詢語言。其實就是定義了操作所有關係型資料庫的一種規則。通用語法規則 sql 語句可以單行或多行書寫,以分號結尾 可使用空格和縮進來增強語句的可讀性 mysql 資料庫的 sql 語句不區分大小寫,關鍵字建議使用大寫 單行注釋 注釋內...