MySQL經常忘的語句

2021-09-28 14:23:16 字數 1125 閱讀 6468

3. 分頁查詢

4. 總結

雖然這是基礎的,但是還是記一下,以便之後鞏固。

alter table a2

modify column id int default 10;

alter table a2

modify column id int;

alter table a2

modify column id int not null;

alter table a2

modify column id int;

alter table a2

add constraint iduk unique(id);

alter table a2

drop drop index id;

注意:這個是比較特殊的

alter table a2

add primary key(id);

alter table a2

drop primary key;

note:由於乙個表的主鍵只可以有乙個所以才可以這樣刪除主鍵

alter table a2

add constraint idfk foreign key (id) references a1(id) on delete cascade;

note:這是級聯刪除

另外乙個就是級聯置空,只要把其中的on delete cascade 改為 on delete set null

alter table a2

drop foreign key idfk;

select * 

from employees

limit 3*4,4

note:這是第四頁,每頁4條記錄

雖然這些東西是簡單的,但是它是常用的,還有一些常用我沒寫,只是把自己經常忘的以及易錯的歸納出來,其他的還有表的建立與修改、表的增刪改以及基礎的查詢。

C 一些經常忘的小東西

1 窗體中的 combobox combobox1.datasource dt com combobox1.displaymember buyer combobox1.valuemember id 2給datagridview賦值,其中有自定義的列 dt umd tu.selectall order...

MySQL中經常用到實用的幾種SQL語句

實用的sql 1.插入或替換 如果我們想插入一條新記錄 insert 但如果記錄已經存在,就先刪除原記錄,再插入新記錄。情景示例 這張表存的每個客戶最近一次交易訂單資訊,要求保證單個使用者資料不重複錄入,且執行效率最高,與資料庫互動最少,支撐資料庫的高可用。此時,可以使用 replace into ...

命令語句 常忘常用常記

方便查詢 刪除資料夾 rm rf 資料夾名移動檔案 安裝vue專案 npm install執行vue專案 npm run dev執行django專案 python3 manage.py runserver 0.0.0.0 8888啟動資料庫服務 service mysqld start建立資料庫命令...