国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

零基礎(chǔ)入門MySQL數(shù)據(jù)庫(全)

這篇具有很好參考價值的文章主要介紹了零基礎(chǔ)入門MySQL數(shù)據(jù)庫(全)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

前言

一切從創(chuàng)建數(shù)據(jù)庫開始
數(shù)據(jù)庫→基本表(創(chuàng)建-增刪改查)→視圖(創(chuàng)建-增刪改查)

一、數(shù)據(jù)類型

1.1 數(shù)值型

int #4個字節(jié)
smallint #2個字節(jié)
tinyint #1個字節(jié)
float   #浮點(diǎn)型
numeric/decimal #小數(shù)

1.2 字符型

char   #固定長度
varchar    #可變長度
text     #文本

1.3 日期型

datetime   #8個字節(jié)
year       #年
date       #天
time       #時間

二、數(shù)據(jù)庫

2.1 創(chuàng)建數(shù)據(jù)庫

create database 數(shù)據(jù)庫名
default character set utf8;

2.2 修改數(shù)據(jù)庫

alter database 數(shù)據(jù)庫名;

2.3 刪除數(shù)據(jù)庫

drop database 數(shù)據(jù)庫名;

三、基本表

3.1 表結(jié)構(gòu)

3.1.1 創(chuàng)建表結(jié)構(gòu)

定義

create table 表名
(
列名  數(shù)據(jù)類型  約束條件,
列名  數(shù)據(jù)類型  約束條件,
……
);

創(chuàng)建學(xué)生表student
唯一性標(biāo)識 id:整型,自動增長列,主鍵
學(xué)號 sno:9個字符,非空,不允許重復(fù)
姓名 sname:20個字符,非空
性別 ssex:2個字符,男或女
年齡 sage:tinyint,15到45之間
系別 sdept:20個字符,默認(rèn)值為計算機(jī)系

create table student
(
id int auto_increment primary key,
sno char(9) not null unique,
sname char(20) not null,
ssex char(2) check(ssex in ('男','女')),
sage smallint check(sage>=15 and sage<=45),
sdept char(20) default '計算機(jī)系'
);

創(chuàng)建課程表course
課程號 cno:4個字符 主鍵
課程名 cname: 50個可變長字符,不允許為空
先修課程號 cpno: 4個字符
學(xué)分 ccredit: smallint
先修課程號 cpno 參照 課程號cno 取值

create table course
(
cno char(4) primary key,
cname varchar(50) not null,
cpno char(4),
ccredit smallint,
foreign key(cpno) references course(cno)
);

創(chuàng)建成績表sc
學(xué)號 sno:9個字符
課程號 cno:4個字符
成績 grade: smallint
sno,cno:組合主鍵
sno參照student表的sno取值
cno參照course表的cno取值

create table sc
(
sno char(9) not null,
cno char(4) not null,
grade smallint,
primary key(sno,cno),
foreign key(sno) references student(sno),
foreign key(cno) references course(cno)
);
3.1.2 修改表結(jié)構(gòu)

定義

alter table 表名 modify 列名 新數(shù)據(jù)類型 約束;

例:修改student的sdept為40個字符寬度

alter table student modify sdept char(40);
3.1.3 增加列

定義

alter table 表名 add 列名 數(shù)據(jù)類型 約束;

例:在student中增加address列

alter table student add address varchar(50) not null;
3.1.4 刪除列

定義

alter table 表名 drop column 列名;

例:刪除student的sage列

alter table student drop column sage;
3.1.5 增加約束

定義

alter table 表名 add constraint 約束名 約束類型(列名);

例:在student中增加sno為主關(guān)鍵字

alter table student add primary key(sno);

例:添加sc的sno列的外碼約束為student的sno

alter table sc add foreign key(sno) references studnet(sno);
3.1.6 刪除約束

定義

alter table 表名 drop 約束類型 約束名

例:刪除student的主鍵約束

alter table student drop primary key
3.1.7 刪除表

定義

drop table 表名

3.2 數(shù)據(jù)查詢

定義

select 查詢目標(biāo)
from 目標(biāo)所在表
where 條件
group by 分組依據(jù)
having 分組條件
order by 排序依據(jù)
limit 限制;
3.2.1 簡單查詢
  1. 查詢?nèi)w學(xué)生的學(xué)號、姓名
select sno,sname from student;
  1. 查詢?nèi)苛?/li>
select * from student;
select * from course;
select * from sc;
  1. 查詢?nèi)w學(xué)生的姓名和出生年份
select sname as 'student name',2023-sage 'birthday' from student;
3.2.2 條件(where)
  1. 查詢計算機(jī)系全體學(xué)生的姓名
select sname 
from student 
where sdept='計算機(jī)系';
  1. 查詢年齡小于20歲的學(xué)生的姓名
select sname 
from student 
where sage<20;
  1. 查詢計算機(jī)系年齡小于20歲的學(xué)生的姓名
select sname 
from student 
where sage<20 and sdept='計算機(jī)系';
  1. 查詢年齡介于22歲到24歲的學(xué)生姓名和年齡
select sname,sage 
from student 
where sage>=22 and sage<=24;
select sname,sage 
from student 
where sage between 22 and 24;
  1. 查詢信息系、數(shù)學(xué)系和計算機(jī)系學(xué)生的姓名和性別
select sname,ssex 
from student 
where sdept='信息系' 
or sdept='數(shù)學(xué)系' 
or sdept='計算機(jī)系';
select sname,ssex 
from student 
where sdept in ('信息系','數(shù)學(xué)系','計算機(jī)系');
  1. 查詢未確定系學(xué)生的基本信息
select * 
from student 
where sdept is null;
  1. 查詢無考試成績的學(xué)生的學(xué)號
select sno 
from sc 
where grade is null;
  1. 查詢有考試成績的學(xué)生的學(xué)號和成績
select sno,grade 
from sc 
where grade is not null;
3.2.3 消除(distinct)
  1. 查詢由哪些學(xué)生選修了課程,只需給出學(xué)號(消除重復(fù)值)
select distinct sno 
from sc;
3.2.4 模糊(like)
  1. 查詢姓王的同學(xué)的基本信息
select * 
from student 
where sname like "王%";
  1. 查詢姓名中有王字的同學(xué)的基本信息
select * 
from student
where sname like "%王%";
3.2.5 排序(order by)
  1. 將學(xué)生按年齡由小到大排序
select * 
from student 
order by sage asc;
  1. 輸出選修c02課程學(xué)生的學(xué)號和成績,按成績降序排序
select sno,grade 
from sc 
where sno='c02' 
order by grade desc;
3.2.6 分組(group by)
  1. 統(tǒng)計學(xué)生的總?cè)藬?shù)
select count(*) 
from student 
group by sno;
  1. 統(tǒng)計選修了課程的學(xué)生的人數(shù)
select count(distinct sno) 
from sc 
group by sno;
  1. 計算學(xué)號為200215121學(xué)生的考試成績總和
select sum(grade) 
from sc 
where sno='200215121' 
group by sno;
  1. 計算c01課程的平均成績
select avg(grade) 
from sc 
where cno='c01' 
group by cno ;
  1. 查詢最大的學(xué)生年齡
select max(sage) 
from student 
group by sno;
  1. 統(tǒng)計每門課的平均成績,輸出課程號和平均成績
select cno,avg(grade) 
from sc 
group by cno;
  1. 統(tǒng)計每門課的選修人數(shù),輸出課程號和課程選修人數(shù)
select cno,count(*) 
from sc 
group by cno;
  1. 查詢每名學(xué)生的選課門數(shù)和平均成績
select sno,count(*),avg(grade) 
from sc 
group by sno;
  1. 查詢選修了3門以上課程的學(xué)生的學(xué)號
select sno 
from sc 
group by sno 
having count(*)>3;
  1. 查詢選課門數(shù)大于等于4門的學(xué)生的平均成績和選課門數(shù)
select sno,avg(grade),count(*) 
from sc
group by sno 
having count(*)>=4;
  1. 查詢選修門數(shù)超過3門,且平均分在70以上的學(xué)生的學(xué)號,選修門數(shù),平均成績,并按成績從高到低排序
select sno,count(*),avg(grade) 
from sc
where grade>=60
group by sno
having count(*)>3 and avg(grade)>70
order by avg(grade) desc;
3.2.7 限制(limit)
  1. 查詢平均成績前三名同學(xué)的學(xué)號,姓名,平均成績
select student.sno,student.sname,avg(sc.grade) from student,sc
where student.sno=sc.sno
group by student.sno
order by avg(sc.grade)
limit 3;
3.2.8 單行輸出(group_concat)
  1. 查詢200215121學(xué)生的選課情況,顯示:學(xué)號,課程號(橫向排列成一行,用’,'分隔)
select sno,group_concat(cno) 
from sc 
where sno='200215121';
  1. 查詢每個學(xué)生的選課情況,顯示:學(xué)號,課程號(橫向排列成一行,用’,'分隔)
select sno,group_concat(cno) 
from sc 
group by sno;
  1. 查詢學(xué)生的選課情況,要求輸出學(xué)號,姓名,課程門數(shù),課程名列表(用逗號分隔),按照學(xué)號升序排序
select student.sno,student.sname,count(sc.cno),
group_concat(cname order by cname separator ',') 
from sc,student,course 
where student.sno=sc.sno 
and course.cno=sc.cno
group by student.sno
order by sno asc;
3.2.9 多表查詢(連接)
  1. 查詢每個學(xué)生的基本信息及其選課情況
select student.sno,sname,ssex,sage,sdept,cno,grade
from student left join sc on student.sno=sc.sno;
  1. 查詢計算機(jī)系學(xué)生的選課情況,要求輸出姓名,課程號,成績
select student.sname,sc.cno,sc.grade 
from student,sc
where student.sno=sc.sno and sdept='計算機(jī)系';
  1. 查詢計算機(jī)系學(xué)生的選課情況,要求輸出姓名,課程名,成績
select student.sname,course.cname,sc.grade 
from student,course,sc
where student.sno=sc.sno 
and course.cno=sc.cno 
and sdept='計算機(jī)系';
  1. 查詢計算機(jī)系學(xué)生的選課情況,要求輸出姓名,課程名
select student.sname,course.cname 
from student,course,sc
where student.sno=sc.sno 
and course.cno=sc.cno 
and sdept='計算機(jī)系';
  1. 查詢學(xué)生的選課情況,要求輸出學(xué)號,姓名,課程代號,成績
select student.sno,student.sname,sc.cno,sc.grade from student,sc
where student.sno=sc.sno;
  1. 查詢學(xué)生的選課情況,要求輸出學(xué)號,姓名,課程代號,成績(包括未選課學(xué)生的信息)
select student.sno,student.sname,sc.cno,sc.grade
from student 
left join sc 
on student.sno=sc.sno;
  1. 查詢各門課程的先修課名稱情況
select a.cno,a.cname,b.cname 
from course a,course b
where a.cpno=b.cno;
3.2.10 子查詢(嵌套)
  1. 查詢與劉晨在同一個系的學(xué)生
select * 
from student 
where sdept=
(select sdept from student where sname='劉晨')
and sname!='劉晨';
  1. 查詢年齡最小的同學(xué)信息
select * 
from student 
where sage=
(select min(sage) from student);
select * 
from student 
order by sage asc 
limit 1;
  1. 查詢有成績大于90分的學(xué)生的學(xué)號和姓名
select student.sno,student.sname 
from student,sc
where student.sno=sc.sno and grade>90;
select sno,sname 
from student 
where sno in
(select sno from sc where grade>90);
  1. 查詢有成績大于90分的學(xué)生的學(xué)號和姓名和成績
select student.sno,student.sname,sc.grade 
from student,sc
where student.sno=sc.sno and grade>90;
  1. 查詢選修了c02課程且成績高于此課程的平均成績的學(xué)生的學(xué)號和成績
select sno,grade 
from sc 
where grade>
(select avg(grade) from sc where cno='c02' group by cno);
  1. 查詢每門課課程且成績高于此課程的平均成績的學(xué)生的學(xué)號和成績
select a.sno,a.grade 
from sc a 
where grade>
(select avg(grade) from sc b 
where a.cno=b.cno 
group by b.cno);
  1. 查詢每個學(xué)生成績高于他選修課的平均成績的學(xué)生的學(xué)號和課程號及成績
select sno,cno,grade 
from sc a 
where grade>
(select avg(grade) 
from sc b 
where b.sno=a.sno);
  1. 查詢其他系中比信息系某一學(xué)生年齡小的學(xué)生姓名和年齡
select sname,sage 
from student 
where sdept!='信息系'and 
sage<
(select max(sage) 
from student 
where sdept='信息系');
select sname,sage 
from student 
where sdept!='信息系' and 
sage<
any(select age 
from student 
where sdept='信息系');
  1. 查詢所有選修了c02的學(xué)生的姓名
select sname 
from student 
where exists
(select * from sc where cno='c02' and sno=student.sno);
select sname from 
student where sno in 
(select sno from sc where cno='c02');
select sname from sc,student 
where sc.sno=student.sno and sno='c02';
  1. 查詢所有未選修c02課程的學(xué)生的姓名
select sname from student 
where not exists
(select * from sc where cno='c02' and sno=student.sno);
select sname 
from student,sc
where student.sno=sc.sno and cno!='c02';
  1. 查詢所有選修了’數(shù)據(jù)庫’課程的學(xué)生的姓名
select sname 
from student,sc,course
where student.sno=sc.sno and course.cno=sc.cno and cname='數(shù)據(jù)庫';
select sname 
from student 
where exists
(select * from sc where cno=(select cno from course where cname='數(shù)據(jù)庫'));
3.2.11 復(fù)雜查詢(exists)
  1. 查詢同時選修了c01和c02課程的學(xué)生的學(xué)號
select sno from sc where cno='c01' and cno='c02';
select distinct sno 
from sc where 
sno in (select sno from sc where sno='c01') and 
sno in (select sno from sc where sno='c02');
select distinct sno 
from sc a 
where exists
(select * from sc b where b.sno=a.sno 
and cno='c01') and exists
(select * from sc c where c.sno=a.sno 
and cno='c02');
  1. 查詢同時選修了’數(shù)據(jù)庫’和’數(shù)據(jù)結(jié)構(gòu)’課程的學(xué)生的學(xué)號
select distinct sno from sc a where
exists(select * from sc b where b.sno=a.sno and 
cno=(select cno from course where cname='數(shù)據(jù)庫'))
and exists(select * from sc c where c.sno=a.sno and cno=(select cno from course where cname='數(shù)據(jù)結(jié)構(gòu)'));
  1. 查詢選修了全部課程的學(xué)生的姓名(即查詢這樣的學(xué)生,沒有一門課是他不選修的)
select sname from student 
where not exists(select * from course
where not exists(select * from sc 
where sno=student.sno and cno=course.cno);
  1. 查詢選修了學(xué)號為’200215122’學(xué)生選修的全部課程的學(xué)號
select distinct sno from sc a
where not exists(select * from sc b 
where sno='200215122' and 
not exists(select * from sc c where
c.sno=a.sno and c.cno=b.cno);
3.2.12 組合查詢(union)
  1. 查詢所有課程名與學(xué)生名并將查詢列命名為name
(select sname as name from student) 
union
(select cname from course);

3.3 數(shù)據(jù)更新

3.3.1 插入(insert)

定義

insert into 表名 (列名) values (值列表);

1. 將新生記錄為(200821105,陳冬,男,18,信息系)插入到student表中

insert into student (sno,sname,ssex,sage,sdept)
values('200821105','陳冬','男',18,'信息系');
insert student
values('200821105','陳冬','男',18,'信息系');

2. 將與劉晨同一個系的新生記錄(200821105,陳冬,男,18)插入到student表中

insert into student set sno='200821105',sname='陳冬',ssex='男',sage=18,
sdept=(select sdept from student where sname='劉晨');

3. 將新生記錄(200821107,陳冬,男,18,信息系),(200821118,劉晨,男,18,信息系)一起插入到student表中

insert into student
values('200821107','陳冬','男',18,'信息系'),('200821108','劉晨','男',18,'信息系');

4. 在sc表中插入一新記錄學(xué)號為200821105,課程為c01

insert into sc (sno,cno) values('200821105','c01',null);
insert into sc values('200821105','c01',null);

5. 備份c01的成績到c01_cj新表中

create table c01_cj like sc;
insert into c01_cj
select * from sc where cno='c01';
3.3.2 修改(update)

定義

update 表名 set 列名=表達(dá)式 where 條件;

1. 將計算機(jī)系全體學(xué)生的成績加5分

update sc set grade=grade+5
where sno in (select sno from student where sdept='計算機(jī)系');

2. 將平均成績80分以上的學(xué)生成績加3分

update sc set grade=grade+3 
where sno in
(select sno from sc group by sno having avg(grade)>80);

3. 將數(shù)據(jù)結(jié)構(gòu)3-5名學(xué)生的成績加5分

update sc set grade=grade+5 where sno=
(select sno from course where course.cno=sc.cno and cname='數(shù)據(jù)結(jié)構(gòu)'
order by grade desc limit 2,4);
3.3.3 刪除(delete)

定義

delete from 表名 where 條件;

1. 刪除學(xué)號為200215121的學(xué)生的記錄

delete from sc where sno='200215121';
delete from student where sno='200215121';

2. 刪除所有學(xué)生的記錄

delete from student;

3. 刪除計算機(jī)系所有學(xué)生的選課記錄

delete from sc where sno in(select sno from student where sdept='計算機(jī)系');

四、視圖

4.1 創(chuàng)建視圖

定義

create view 視圖名 as 子查詢;

1. 建立系名為計算機(jī)系的學(xué)生的視圖

create view student_view as
select sno,sname,ssex,sdept from student 
where sdept='計算機(jī)系';

2. 建立系名為計算機(jī)系的學(xué)生的視圖,要求對視圖的更新進(jìn)行檢查

create view student_view as
select sno,sname,ssex,sdept 
from student 
where sdept='計算機(jī)系'
with check option;

3. 建立信息系選修了c01課程的學(xué)生的視圖

create view student_view as
select student.sno,student.sname,sc.grade
from student,sc 
where student.sno=sc.sno 
and sdept='信息系' 
and cno='c01';

4.2 其他

同基本表操作一樣

總結(jié)

數(shù)據(jù)庫→基本表(創(chuàng)建-增刪改查)→視圖(創(chuàng)建-增刪改查)文章來源地址http://www.zghlxwxcb.cn/news/detail-406524.html

附:更多內(nèi)容

序號 相關(guān)內(nèi)容 直達(dá)鏈接
1 零基礎(chǔ)入門MySQL數(shù)據(jù)庫(全) https://want595.blog.csdn.net/article/details/129997567
2 MySQL語句的所有模型(詳細(xì)) https://want595.blog.csdn.net/article/details/130044517
3 MySQL的not exists與雙重否定(模板) https://want595.blog.csdn.net/article/details/129990153

到了這里,關(guān)于零基礎(chǔ)入門MySQL數(shù)據(jù)庫(全)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【Mysql數(shù)據(jù)庫從0到1】-入門基礎(chǔ)篇--mysql基本使用

    【Mysql數(shù)據(jù)庫從0到1】-入門基礎(chǔ)篇--mysql基本使用

    mysql5.7和之前版本,默認(rèn)字符集為latin1,插入中文字符會出現(xiàn)亂碼。在使用5.7及之前的版本時候需要將字符編碼修改為utf8字符集,utf8字符集指的是utf8mb3。 從mysql8.0開始,數(shù)據(jù)庫默認(rèn)字符編碼改為utf8mb4。 Mysql 5.7 默認(rèn)身份插件是 mysql_native_password Mysql 8.0 默認(rèn)的身份插件是 cac

    2024年02月07日
    瀏覽(20)
  • MySQL數(shù)據(jù)庫入門到精通1--基礎(chǔ)篇(MySQL概述,SQL)

    MySQL數(shù)據(jù)庫入門到精通1--基礎(chǔ)篇(MySQL概述,SQL)

    目前主流的關(guān)系型數(shù)據(jù)庫管理系統(tǒng): Oracle:大型的收費(fèi)數(shù)據(jù)庫,Oracle公司產(chǎn)品,價格昂貴。 MySQL:開源免費(fèi)的中小型數(shù)據(jù)庫,后來Sun公司收購了MySQL,而Oracle又收購了Sun公司。 目前Oracle推出了收費(fèi)版本的MySQL,也提供了免費(fèi)的社區(qū)版本。 SQL Server:Microsoft 公司推出的收費(fèi)的中

    2024年02月07日
    瀏覽(21)
  • MySQL-創(chuàng)建和管理表:基礎(chǔ)知識、創(chuàng)建和管理數(shù)據(jù)庫、創(chuàng)建表、修改表、重命名表、刪除表、清空表、拓展

    MySQL-創(chuàng)建和管理表:基礎(chǔ)知識、創(chuàng)建和管理數(shù)據(jù)庫、創(chuàng)建表、修改表、重命名表、刪除表、清空表、拓展

    注:此為筆者學(xué)習(xí)尚硅谷-宋紅康MySQL的筆記,其中包含個人的筆記和理解,僅做學(xué)習(xí)筆記之用,更多詳細(xì)資訊請出門左拐B站:尚硅谷!!! 1.1 一條數(shù)據(jù)存儲的過程 存儲數(shù)據(jù)是處理數(shù)據(jù)的第一步 。只有正確地把數(shù)據(jù)存儲起來,我們才能進(jìn)行有效的處理和分析。否則,只能是一團(tuán)

    2024年04月11日
    瀏覽(94)
  • 【Mysql數(shù)據(jù)庫從0到1】-入門基礎(chǔ)篇--用戶與權(quán)限管理

    【Mysql數(shù)據(jù)庫從0到1】-入門基礎(chǔ)篇--用戶與權(quán)限管理

    Mysql 用戶分為root用戶和普通用戶,其中root用戶是數(shù)據(jù)庫超級管理員,擁有所有權(quán)限(創(chuàng)建、刪除、修改密碼、授權(quán)等管理權(quán)限),普通用戶只擁有被授予的權(quán)限。 Mysql數(shù)據(jù)庫的安全性通過賬戶管理來保障。 1.1 ?? Mysql服務(wù)器登錄 ?? 簡單使用 ?? 復(fù)雜使用 1.2 ?? 用戶創(chuàng)建

    2024年02月07日
    瀏覽(27)
  • 【MySQL 】MySQL 創(chuàng)建數(shù)據(jù)庫, MySQL 刪除數(shù)據(jù)庫,MySQL 選擇數(shù)據(jù)庫

    【MySQL 】MySQL 創(chuàng)建數(shù)據(jù)庫, MySQL 刪除數(shù)據(jù)庫,MySQL 選擇數(shù)據(jù)庫

    作者簡介: 辭七七,目前大一,正在學(xué)習(xí)C/C++,Java,Python等 作者主頁: 七七的個人主頁 文章收錄專欄: 七七的閑談 歡迎大家點(diǎn)贊 ?? 收藏 ? 加關(guān)注哦!???? 我們可以在登陸 MySQL 服務(wù)后,使用 create 命令創(chuàng)建數(shù)據(jù)庫,語法如下: 以下命令簡單的演示了創(chuàng)建數(shù)據(jù)庫的過程,

    2024年02月13日
    瀏覽(114)
  • MySQL(1)
MySQL創(chuàng)建數(shù)據(jù)庫和創(chuàng)建數(shù)據(jù)表

    MySQL(1) MySQL創(chuàng)建數(shù)據(jù)庫和創(chuàng)建數(shù)據(jù)表

    創(chuàng)建數(shù)據(jù)庫 1. 連接 MySQL? ? ? mysql -u root -p? 2. 查看當(dāng)前的數(shù)據(jù)庫? show databases; 3. 創(chuàng)建數(shù)據(jù)庫? create database 數(shù)據(jù)庫名; 創(chuàng)建數(shù)據(jù)庫 4. 創(chuàng)建數(shù)據(jù)庫時設(shè)置字符編碼??create database 數(shù)據(jù)庫名 character set utf8;? 5. 查看和顯示數(shù)據(jù)庫的編碼方式? show create database 數(shù)據(jù)庫名; 顯示數(shù)據(jù)庫的

    2024年02月14日
    瀏覽(119)
  • mysql-數(shù)據(jù)庫-創(chuàng)建列表

    mysql-數(shù)據(jù)庫-創(chuàng)建列表

    mysql select database(); ?完成這些操作后,就可以對該列表進(jìn)行添加數(shù)據(jù)(增刪改查)等操作。 如果語法沒有問題,就會顯示已添加成功的提示: ?當(dāng)列表創(chuàng)建完成后,就可以查看列表的各種信息了: 查看列表的數(shù)據(jù)結(jié)構(gòu)(使用什么字段): 查看是否增加成功: ?查看是否修改

    2024年02月14日
    瀏覽(18)
  • Mysql--創(chuàng)建數(shù)據(jù)庫(1)

    Mysql--創(chuàng)建數(shù)據(jù)庫(1)

    我們可以在登陸 MySQL 服務(wù)后,使用 create 命令創(chuàng)建數(shù)據(jù)庫,語法如下: 以下命令簡單的演示了創(chuàng)建數(shù)據(jù)庫的過程,數(shù)據(jù)名為 R OB: 建數(shù)據(jù)庫的基本語法如下: 如果你希望在創(chuàng)建數(shù)據(jù)庫時指定一些選項,可以使用 CREATE DATABASE 語句的其他參數(shù),例如,你可以指定字符集和排序規(guī)則

    2024年01月24日
    瀏覽(45)
  • k8s創(chuàng)建數(shù)據(jù)庫mysql
MySQL數(shù)據(jù)庫之日志管理

    k8s創(chuàng)建數(shù)據(jù)庫mysql MySQL數(shù)據(jù)庫之日志管理

    ?本文使用的是本機(jī)掛載數(shù)據(jù),這樣存在一個弊端沒有pvc掛載好? 重點(diǎn)來了: 這種共享宿主機(jī)存儲的方法似乎可以解決Mysql數(shù)據(jù)庫數(shù)據(jù)恢復(fù)的場景,我們似乎可以萬事大吉了! But ,有的老鐵會問:如果我得宿主機(jī)掛了怎么辦?或者Pod沒有在上一次節(jié)點(diǎn)上拉起,而是在新的節(jié)點(diǎn)

    2023年04月27日
    瀏覽(302)
  • MySQL創(chuàng)建數(shù)據(jù)庫和數(shù)據(jù)表

    MySQL創(chuàng)建數(shù)據(jù)庫和數(shù)據(jù)表

    文章目錄 前言 一、MySQL數(shù)據(jù)庫是什么? 二、使用步驟 1.顯示當(dāng)前數(shù)據(jù)庫 2.創(chuàng)建數(shù)據(jù)庫 ???????? 3.使用數(shù)據(jù)庫 ???????? 4.刪除數(shù)據(jù)庫 ???????? 5.表的操作 ??? 5.1 顯示數(shù)據(jù)庫中的表 ??? 5.2 創(chuàng)建表 ? ? 5.3 刪除表 ???????? 6.總結(jié) MySQL數(shù)據(jù)庫的創(chuàng)建操作 是一個客戶

    2023年04月08日
    瀏覽(904)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包