風(fēng)哥MySQL數(shù)據(jù)庫高級工程師
2023-07-29 13:37 作者:bili_93891819972 | 我要投稿
對于MySQL數(shù)據(jù)庫的操作
命令為:
CREATE創(chuàng)建 DROP刪除 SHOW查看 ALTER修改庫或者表的結(jié)構(gòu)
查看所有的數(shù)據(jù)庫
mysql> show databases;
選擇數(shù)據(jù)庫
use 庫名
查看當(dāng)前所在的數(shù)據(jù)庫
select database()
查看當(dāng)前庫下 所有的表
show tables()
創(chuàng)建數(shù)據(jù)庫
create database 庫名
查看創(chuàng)建庫的信息
show create database 庫名
創(chuàng)建一個不存在的數(shù)據(jù)庫 python 如果存在在不創(chuàng)建 不存在則創(chuàng)建 (不管在不在 都執(zhí)行成功 防止報錯)
create database if not exists 庫名
刪除數(shù)據(jù)庫
drop database 庫名
刪除數(shù)據(jù)庫 防止報錯
drop database if exists 庫名
設(shè)置數(shù)據(jù)庫的字符集
alter database 庫名 character set utf8/latin1(之前數(shù)據(jù)庫默認(rèn)latin1)
創(chuàng)建庫 并設(shè)置字符集 在該庫下創(chuàng)建的表和字段 默認(rèn)都為 utf8字符編碼
create database 庫名 character set utf8
標(biāo)簽: