MySQL--數據的增刪改(查在下一節單講)

- 增加 insert into ... values(...)  insert into 表名;values()要包含全部的數據;  insert into 表名(字段);values()只需要列舉對應的數據; | 全列插入 insert into students values(0,'郭靖',1,'蒙古','2016-1-2'); | 部分插入 insert into students (name, birth) values ("王二", “2008-08-08”); | 多行插入 insert into students (name, birth) values ("劉備", "1000-08-08"), ("張飛", "1000-08-08"); - 修改(更新) | 根據where後面的條件,修改字段 update 表名 set 列1=值1... where 條件(相同的數據) update students set age=21; update students set age=18 where id=1; update students set age=10,gender=4 where id=1; - 刪除 | 物理刪除 delete from 表名 where 條件; delete from students where id=1; | 邏輯刪除 # 數據沒有真實刪除, # 只是添加了一個是否在使用中的標記 --添加一個is_delete字段,數據類型爲二進制 alter table students add is_delete bit; --給字段添加默認值 alter table students add is_delete bit; --修改字段的值,來正確標記是否在使用中 alter table students set is_delete=1 where id=1;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章