簡單操作crud

2021-06-18 04:44:10 字數 952 閱讀 8697

資料的操作:dml

建立資料(插入資料):

insert into tbl_name(字段列表) values(值列表)

>insert into exam_student (name, stu_no) values('zhangsan', 'php001');

如果需要在插入時,為所有的字段設定值,那麼可以省略字段列表。

要求是值的順序,應該與表中字段的順尋一致。

>insert into exam_student values ('xiaowu', 'php002');

獲得資料(查詢資料):

select 字段列表 from 表名 查詢條件

>select * from exam_student;

>select * from exam_student where 1;

>select name, stu_no from exam_student;

字段列表可以使用*代替,表示所有的字段。

查詢條件可以省略,表示所有的記錄都獲得,相當於where 1;

有條件的:

>select * from exam_student where fenshu>=72;

刪除資料:

delete from tbl_name 條件

>delete from exam_student where fenshu<72;

刪除需要在邏輯上嚴格給條件,否則容易早場資料誤操作,導致損失。

語法上可以沒有where。

可以:如果需要刪除所有資料,使用where 1;

修改資料:

update tbl_name set 字段=新值,... 條件

>update exam_student set fenshu=100 fenshu>=72;

crud:

create, read(retrieve), update, delete

簡單操作crud

資料的操作 dml 建立資料 插入資料 insert into tbl name 字段列表 values 值列表 insert into exam student name,stu no values zhangsan php001 如果需要在插入時,為所有的字段設定值,那麼可以省略字段列表。要求是...

SQL 簡單的 CRUD 操作

sql 是用於訪問和處理資料庫的標準的計算機語言,全稱是 structured query language。注 sql 對大小寫不敏感,select 和 select 是相同的。insert into table name values value1,value2,value3,或者insert ...

MyBatis Plus的CRUD 簡單操作

crud 是指在做計算處理時的增加 create 讀取查詢 retrieve 更新 update 和刪除 delete 幾個單詞的首字母簡寫。增加操作 resource test public void insert 執行完成後的 查詢操作 test public void selectbyname...