索引:
一種快速定位技術,相當于一本書的目錄頁.
作用:快速查詢數據 條件:數據條目大于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)建主鍵索引(已經創(chuàng)建了表,沒有指定主鍵,然后修改表加入主鍵,主鍵索引會自動創(chuàng)建)
alter table info change id id int(10);//刪除自增長
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)建多列索引
事務:
一組操作共同執(zhí)行或者都不執(zhí)行,結果保持一致。
特性:原子性、一致性、隔離性、持久性。
例如:銀行轉賬
姓名 | 余額 | 條件:余額>0 |
Zhangsan |
100 |
/ |
lisi |
200 |
/ |
注:Zhangsan 轉賬100給 to lisi

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