-
概念:
按照數(shù)據(jù)結(jié)構(gòu)來組織、管理、存放數(shù)據(jù)的庫
數(shù)據(jù)庫=表+表之間的關(guān)系
-
常見數(shù)據(jù)庫
MySQL、Oracle、MongoDB、SQLServer、Redis、Sqlite
-
數(shù)據(jù)庫與SQL的關(guān)系
數(shù)據(jù)庫是用來存放數(shù)據(jù)的,SQL語句用來操作數(shù)據(jù)庫的數(shù)據(jù)
-
MySQL
- 卸載:關(guān)閉服務(wù)、卸載軟件MySQL、刪除安裝MySQL路徑剩余的文件、ProgramData的MySQL文件刪除
- 安裝:雙擊 → ... → 安裝類型(Custom)→ 修改安裝路徑 → finish
- 配置
- 關(guān)閉開啟服務(wù)
- 登錄:
mysql -u root -p123 - 退出:
exit、ctrl+c
-
SQL語句
-
DDL:數(shù)據(jù)庫定義語言
# 庫 create database 庫名; show databases; use 庫名; drop database 庫名; show create database 庫名; # 表 show tables; show tables from 其他庫名; create table 表名( id int primary key auto_increment, name varchar(20) unique not null, salary float(6,2), birthday date ); desc 表名; drop table 表名; # 如果插入中文 # 通知服務(wù)器客戶端使用的編碼是gbk set character_set_client=gbk; # 通知服務(wù)器客戶端查看結(jié)果集使用的編碼是 gbk set character_set_results=gbk; # 如果中文對(duì)不齊或亂碼 charset gbk;面試題:delete和truncate的區(qū)別?
-
DML:數(shù)據(jù)庫操作語言
insert into 表名 values(1,'anfly',1.22,'1991-01-01'); insert into 表名(id,name) vlaues(2,'bigfly'); delete from 表名 [where 條件]; truncate table 表名; update 表名 set name="",salery="" where 條件; -
DQL:數(shù)據(jù)庫查詢語言
# 查 select */name from 表名 [where id!><=1]; # 并列、別名、修改數(shù)據(jù) select name as 姓名 , (math+chinese) as 數(shù)語和,(math10) as 數(shù)學(xué)加10 from 表名; # 條件合并 select * from student where (math+english+chinese)>230; # 范圍:between a and b,a和b都包含 select * from 表名 where math between 80 and 90; # 條件并列:and select * from 表名 where math > 80 and chinese > 90; # 匹配枚舉值:in select * from 表名 where math in(10,20,30); # 模糊查詢:like,"_"代表一個(gè)字符,"%"代表(0,∞) select * from 表名 where name like '_%'; # 聚合函數(shù) max count min sum avg # 分組 select sex,count(*) from 表名 group by sex; # 分頁查詢 select * from 表名 limit 2,5; # 排序 select * from 表名 order by math asc/desc limit2,5; DCL:數(shù)據(jù)庫控制語言
-
-
多表設(shè)計(jì)
-
一對(duì)一、一對(duì)多、多對(duì)多
# 外鍵 create table t(id int primary key,name varchar(100)); create table s (id int primary key,name varchar(100)); create table ts(t_id int,s_id int,constraint foreign key(t_id) references t(id),constraint foreign key(s_id) references s(id)); # 李老師所有學(xué)生 select * from s where id in(select s_id from ts where t_id=(select id from t where name = '李老師')); # 張三的所有老師 select * from t where id in(select t_id from ts where s_id=(select id from s where name = '張三')); -
多表聯(lián)查
-
交叉查詢
# AB表 select * from A,B; select * from A cross join B; -
內(nèi)連接查詢
select * from A inner join B on A.id=B.id; select * from A , B where A.id=B.id; -
外連接查詢
# 左外 select * from A left join B on A.id=B.id; # 右外 select * from A right join B on A.id=B.id;面試題:左外和右外的區(qū)別?
-
-
-
Navicat
下載、安裝、破解
-
操作
連接數(shù)據(jù)庫、建庫、刪庫、建表、刪表、插入數(shù)據(jù)、刪除數(shù)據(jù)、導(dǎo)出、導(dǎo)入
-
數(shù)據(jù)庫優(yōu)化
索引優(yōu)化
-
數(shù)據(jù)庫性能檢測工具
explain
數(shù)據(jù)庫視圖
數(shù)據(jù)庫
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 引入 : 數(shù)據(jù)保存的三種方式 數(shù)據(jù)保存到內(nèi)存:優(yōu)點(diǎn):讀寫非常快缺點(diǎn):程序關(guān)閉導(dǎo)致數(shù)據(jù)丟失 數(shù)據(jù)保存到文件:優(yōu)點(diǎn):數(shù)...
- /*CREATE TABLE student3 (id int, -- 編號(hào)name varchar(20), ...
- 1. 為什么軟件測試工程師還需要學(xué)習(xí)數(shù)據(jù)庫以及開發(fā)方面的知識(shí)? 測試工程師的目的是找出軟件的不足,并告訴開發(fā)工程師...
- 一、數(shù)據(jù)庫概述 1.為什么軟件測試工程師還需要學(xué)習(xí)數(shù)據(jù)庫以及開發(fā)方面的知識(shí)? ●測試工程師在測試軟件過程中,不僅僅...
- 數(shù)據(jù)庫對(duì)于后端開發(fā)來說是必不可少所要用到的,而MySQL數(shù)據(jù)庫是其中的主流之一,在中小型公司中使用的較為廣泛,作為...