六天玩轉mysql筆記 mysql學習筆記 第六天

2021-10-19 04:50:39 字數 1013 閱讀 7521

改變資料表的結構:

alter table tb_name action,[action,action](使用alter table 之前,需要檢視資料表的當前定義,需要執行show create table 語句 )

alter table tb_name modify columns+資料型別

alter table tb_name change column_name column_new_name+資料型別

change 能夠改變表名和資料型別,modfy只能改變資料型別

你也可以改變字符集:alter table tb_name modify t char(20) character set usc2

對於資料列來說,當兩個資料列具有相同的資料列的時候,比較的時候速度會快許多

t1.name char(20)與t2.name char(15)

比t1.namechar(20)與t2.name char(20)的比較會更慢

改變儲存引擎:

alter table table_name engine=engine_name如果資料列包括blob資料列,那麼不能轉化為memory引擎,

因為memory引擎不支援blob,

當innodb定義外檢約束的時候,在轉換儲存引擎的時候,外來鍵會丟失,只有innodb支援外來鍵

重新命名乙個資料表

(1)alter table tb1_name rename to new_tb1_name

(2)rename table tb1_name to new_tb1_name

alter table 一次只能修改乙個資料表,但是rename ...to 可以是多個一起修改的:rename table t1 to t2,t2 to t3,...

如果在重新命名的時候加上資料庫的字首,可以把資料表從乙個資料庫遷移到另乙個資料庫裡

alter table a.tb1_name rename tob.tb1_name

或renametable a.tb1_name to b.tb1_name

六天帶你玩轉Mysql筆記 第四天

1.連線查詢 1.1 連線查詢分類 1.1.1交叉連線 1.1.2 內連線 1.1.3 外連線 1.1.4 自然連線 natural join 1 連線查詢 將多張表 大於 2張 進行記錄的連線 按照某個指定的條件進行資料拼接 最終結果是記錄數有可能變化,字段數一定會增加 至少兩張表合併 2 連線查...

mysql學習筆記 第六天

改變資料表的結構 alter table tb name action,action,action 使用alter table 之前,需要檢視資料表的當前定義,需要執行show create table 語句 alter table tb name modify columns 資料型別 alter...

Python一百天之第32天筆記 玩轉Linux

which 查詢命令所在目錄 find 搜尋命令 find home name 125.txt 在 home下搜尋以125.txt為名的檔案 ctrl c 停止搜尋 find home iname abc 搜尋不區分大小寫的abc為名的檔案 find home size 1 搜尋大小小於乙個資料塊 ...