溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

操作MySQL --2數(shù)據(jù)的簡單步驟

發(fā)布時間:2020-05-09 14:03:37 來源:億速云 閱讀:191 作者:三月 欄目:MySQL數(shù)據(jù)庫

本文主要給大家簡單講講操作MySQL --2數(shù)據(jù)的簡單步驟,相關專業(yè)術語大家可以上網(wǎng)查查或者找一些相關書籍補充一下,這里就不涉獵了,我們就直奔主題吧,希望操作MySQL --2數(shù)據(jù)的簡單步驟這篇文章可以給大家?guī)硪恍嶋H幫助。

操作MySQL --2數(shù)據(jù)的簡單步驟

#查詢
select  from 表名
例:
select  from students;


#增加
全列插入:insert into 表名 values(...)
例:
insert into students values(0,"黃蓉","1990-01-01",0,0);

缺省插入:insert into 表名(列1,...) values(值1,...)
例:
insert into students ("name","gender") values("郭靖",1);

同時插入多條數(shù)據(jù):insert into 表名 values(...),(...)...;
例:
insert into students values(0,"小龍女","1992-02-03",0,0),(0,"楊過","1991-01-01",1,0);

或insert into 表名(列1,...) values(值1,...),(值1,...)...;
例:
insert into students("name","gender") values("雕",1),("郭襄",0);

#Mysql 可以同時插入多條數(shù)據(jù),Mysql 特有的功能。


#修改
update 表名 set 列1=值1,... where 條件
若不加 where 條件,則修改所有列;

例:
update students set birthday="1980-02-01" where name="郭靖";

#修改多個values:
update students set name="蓉兒" birthday="1988-01-01" where name="黃蓉";


#刪除
#物理刪除
delete from 表名 where 條件
例:delete from students where id=5;

#邏輯刪除

update students isdelete=1 where ...; //增加isDelete列,默認值為0,刪除則將值改成1
例:
update students isDelete=1 where id=6;

查詢時只查詢isDelete=0的數(shù)據(jù)達到刪除效果
select * from students where isDelete=0;

操作MySQL --2數(shù)據(jù)的簡單步驟就先給大家講到這里,對于其它相關問題大家想要了解的可以持續(xù)關注我們的行業(yè)資訊。我們的板塊內(nèi)容每天都會捕捉一些行業(yè)新聞及專業(yè)知識分享給大家的。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI