索引:
一種快速定位技術(shù),相當(dāng)于一本書(shū)的目錄頁(yè).
作用:快速查詢(xún)數(shù)據(jù) 條件:數(shù)據(jù)條目大于2000條
create index id_index on info (id); //創(chuàng)建普通索引
show index from info \G //查看索引
drop index id_index from on info; //刪除索引
create unique index unique_id_index on info (id); //創(chuàng)建唯一索引
alter table info add primary key (id); //創(chuàng)建主鍵索引(已經(jīng)創(chuàng)建了表,沒(méi)有指定主鍵,然后修改表加入主鍵,主鍵索引會(huì)自動(dòng)創(chuàng)建)
alter table info change id id int(10);//刪除自增長(zhǎng)
alter table info drop primary key;//刪除主建
alter table info add column age int; //添加列
alter table info drop column age int; //刪除列
create table infos (descript TEXT,FULLTEXT(descript)); //創(chuàng)建全文索引
create index multi_index on info(name,address); //創(chuàng)建多列索引
事務(wù):
一組操作共同執(zhí)行或者都不執(zhí)行,結(jié)果保持一致。
特性:原子性、一致性、隔離性、持久性。
例如:銀行轉(zhuǎn)賬
姓名 | 余額 | 條件:余額>0 |
Zhangsan |
100 |
/ |
lisi |
200 |
/ |
注:Zhangsan 轉(zhuǎn)賬100給 to lisi

讓客戶(hù)滿(mǎn)意是我們工作的目標(biāo),不斷超越客戶(hù)的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶(hù),將通過(guò)不懈努力成為客戶(hù)在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名注冊(cè)、網(wǎng)站空間、營(yíng)銷(xiāo)軟件、網(wǎng)站建設(shè)、銀川網(wǎng)站維護(hù)、網(wǎng)站推廣。
事務(wù)固定格式:
begin 開(kāi)始
Update bank set money=money+100 where name=’lisi’
Update bank set money=money-100 where name=’zhangsan’
commit 提交
rollback 回滾
補(bǔ)充:
set autocommit = 1; //開(kāi)啟自動(dòng)提交
set autocommit = 0; //禁止自動(dòng)提交
savepoint s2; //定義回滾點(diǎn)
rollback to savepoint s2; //回滾到S2 (相當(dāng)于虛擬機(jī)還原快照)
視圖:
視圖是 數(shù)據(jù)庫(kù)中的虛擬表。
作用:一張表中的數(shù)據(jù)給不同的權(quán)限用戶(hù)提供訪(fǎng)問(wèn)
舉例:公司員工績(jī)效工資考核表:
工號(hào) | 姓名 | 年齡 | 崗位 | 績(jī)效 | 工資 |
1 |
Tom |
50 |
總裁 |
/ |
100萬(wàn) |
2 |
Jerry |
40 |
總監(jiān) |
90 |
20萬(wàn) |
3 |
charry |
30 |
云計(jì)算工程師 |
80 |
12萬(wàn) |
4 |
Jack |
24 |
云計(jì)算工程師 |
90 |
15萬(wàn) |
語(yǔ)法: create view 視圖名稱(chēng) AS select 語(yǔ)句
create view scoreview as select from info where score > 80; //創(chuàng)建視圖(條件:成績(jī)>80)
select * from score_view; //查看視圖
update score_view set score=88 where id=1; //id1的成績(jī)更新為88
drop view if exists score_view; //刪除視圖
總結(jié):
1.數(shù)據(jù)庫(kù)索引分為普通索引、唯一性索引、主鍵索引、全文索引、多列索引;
2.數(shù)據(jù)庫(kù)索引可以協(xié)助快速查詢(xún)表中數(shù)據(jù),但并不是任何字段都需要?jiǎng)?chuàng)建索引;
3.數(shù)據(jù)庫(kù)事務(wù)的ACID特性:原子性、一致性、隔離性、持久性;
4.MySQL事務(wù)命令有begin、rollback、commit、savepoint;
網(wǎng)頁(yè)標(biāo)題:Mysql索引、事務(wù)、視圖常用命令及要點(diǎn)歸納
當(dāng)前路徑:http://www.chinadenli.net/article18/ggiegp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、網(wǎng)站導(dǎo)航、網(wǎng)站制作、建站公司、電子商務(wù)、小程序開(kāi)發(fā)
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源:
創(chuàng)新互聯(lián)