Mysql学習ノート03--尚シリコンバレー李玉婷先生mysql課程


ステップ7:サブクエリ
意味:
                 select  ,      select  ,         
        ,         

特徴:
1、          
2、       from  、select  、where  、having  ,          
3、           ,              
4、                    :
①      
	       
	           :> < = <> >= <= 
	          :
	a、          
	b、        
	
②      
	      
	           :any、all、in、not in
	in:                
	any all           

ステップ8:ページングクエリー
適用シーン:
   web                      sql  

構文:
select   |   ,...
from  
【where   】
【group by     】
【having   】
【order by      】
limit 【       ,】   ;

特徴:
1.       0  

2.limit           

3.  :select * from    limit (page-1)*sizePerPage,sizePerPage
  :
       sizePerPage
       page

##ステップ9:共同クエリー
導入:union連合、連結
構文:
select   |  |   |   【from  】 【where   】 union 【all】
select   |  |   |   【from  】 【where   】 union 【all】
select   |  |   |   【from  】 【where   】 union  【all】
.....
select   |  |   |   【from  】 【where   】

特徴:
1、                  
2、                  
3、union    ,union all     

DML言語
挿入
構文:insert intoテーブル名(フィールド名,...)values(値1,...);
特徴:
1、             ,      
2、       ,       ,  null  
3、        ,     
4、             
5、      ,       ,              

変更
単一テーブル構文を変更するには、次の手順に従います.
update    set   =  ,  =  
【where   】

マルチテーブル構文を変更するには、次の手順に従います.
update  1   1, 2   2
set   =  ,  =  
where     
and     

削除
方式1:delete文
単一テーブルの削除:★delete fromテーブル名【whereフィルタ条件】
マルチテーブルの削除:delete別名1、別名2 fromテーブル1別名1、テーブル2別名2 where接続条件andフィルタ条件;
方式2:truncate文
truncate table   

2つの方法の違い【面接問題】
#1.truncate   where  , delete   where  

#2.truncate       

#3.truncate            ,       ,   1  
#delete           ,       ,            

#4.truncate      ,delete      

DDL文
ライブラリとテーブルの管理
ライブラリの管理:
 、   
create database   
 、   
drop database   

テーブルの管理:
1.テーブルの作成
CREATE TABLE IF NOT EXISTS stuinfo(
	stuId INT,
	stuName VARCHAR(20),
	gender CHAR,
	bornDate DATETIME
	

);

DESC studentinfo;

2.表alterの変更
  :ALTER TABLE    ADD|MODIFY|DROP|CHANGE COLUMN     【    】;

# ①     
ALTER TABLE studentinfo CHANGE  COLUMN sex gender CHAR;

#②    
ALTER TABLE stuinfo RENAME [TO]  studentinfo;
#③           
ALTER TABLE studentinfo MODIFY COLUMN borndate DATE ;

#④    

ALTER TABLE studentinfo ADD COLUMN email VARCHAR(20) first;
#⑤    
ALTER TABLE studentinfo DROP COLUMN email;


#3.   

DROP TABLE [IF EXISTS] studentinfo;

一般的なタイプ
  :
	
  :
	   
	   
   :
   :
Blob  :

一般的な制約
NOT NULL
DEFAULT
UNIQUE
CHECK
PRIMARY KEY
FOREIGN KEY

データベーストランザクション
意味
          (  DML——sql  ),                 

特長
(ACID)
   :     ,     
   :                  
   :                    ,                  
   :        ,          ,            

関連手順:
1、    
2、             (  sql  )
3、         

トランザクションの分類:
明示的なオープンおよび終了トランザクションのフラグがない暗黙トランザクション
  
insert、update、delete          

明示的なトランザクションで、トランザクションのオンと終了が明らかなフラグ
	1、    
	           
	
	2、             (  sql  )
	insert
	update
	delete
	
	3、         

使用したキーワード
set autocommit=0;
start transaction;
commit;
rollback;

savepoint    
commit to   
rollback to   

トランザクションの独立性レベル:
トランザクションの同時問題はどのように発生しますか?
                     

トランザクションの同時問題は何ですか?
  :                    
     :      ,           
  :         ,          ,                  

トランザクションの同時発生を回避するにはどうすればいいですか?
           
1、READ UNCOMMITTED
2、READ COMMITTED       
3、REPEATABLE READ       、           
4、SERIALIZABLE      、        

独立性レベルの設定:
set session|global  transaction isolation level      ;

独立性レベルの表示:
select @@tx_isolation;