My Sql 語法收集 待續

2021-06-02 12:19:11 字數 1031 閱讀 5953

1. alter:

alter [ignore] table tbl_name alter_spec [, alter_spec ...]

alter_specification:

add [column] create_definition [first | after column_name ]

or add index [index_name] (index_col_name,...)

or add primary key (index_col_name,...)

or add unique [index_name] (index_col_name,...)

or alter [column] col_name

or change [column] old_col_name create_definition

or modify [column] create_definition

or drop [column] col_name

or drop primary key

or drop index index_name

or rename [as] new_tbl_name

or table_options

示例: (列定義 包括列名,資料型別,是否可為null,comment 等)

1.1 新增列:

alter table 表名 add  [column] 列定義 [first | after 列名]

1.2 刪除列: alter table  表名 drop [column] 列名

1.3 修改列屬性: alter table

表名  modify  [column]   列定義 comment '說明' after [列名]

1.4 修改列名(可同時修改列屬性): alter table 表名 change [column] 舊列名 新列定義 [first | after 列名]

1.5 修改表名: alter table 表名 rename [to] 新錶名

mysql優化(待續)

like keyword 索引失效,使用全表掃瞄。但可以通過翻轉函式 like前模糊查詢 建立翻轉函式索引 走翻轉函式索引,不走全表掃瞄。like keyword 索引有效。like keyword 索引失效,也無法使用反向索引。一 使用下面的函式來進行模糊查詢,如果出現的位置 0,表示包含該字串。...

MarkDown基礎語法(收集)

空格 一級標題 空格 二級標題 快捷鍵 ctrl 1 一級標題 ctrl 2 二級標題 依此類推 加粗 字元兩邊加兩個 快捷鍵 ctrl b 斜體 字元兩邊加乙個 快捷鍵 ctrl i 加粗 斜體 字元兩邊三個 快捷鍵 ctrlb ctrli 不分先後 下劃線 字元兩邊 快捷鍵 ctrl u 刪除線...

MySQL 學習筆記 待續

資訊和資料 關係資料庫系統 實體 聯絡 模型 實體 客觀事物在資訊世界中稱為實體 entity 它是現實世界中任何可區分 識別的食物 屬性 描述實體或者聯絡的性質或者特徵的資料項 聯絡 反應事物內部或事物之間的關聯集合 常見的實體聯絡有三種 一對 一 一對多 多對多 關係模型 relational ...