(MySql)數(shù)據(jù)庫(kù) 基礎(chǔ)增刪改查

注意事項(xiàng):

1.默認(rèn)自增用0,null, default

2.多個(gè)字段英文逗號(hào)表示

3.vachar用雙引號(hào)

4.所有的符號(hào)用英文表示

一.創(chuàng)建表

創(chuàng)建表

creat table 表名(

id int unsigened priary key auto_increment,

name varchar(10),

添加字段:alter table 表名 add 列名 int

二.簡(jiǎn)單查詢

查詢?nèi)浚簊elect *from 表名

查詢列:select 字段名,from 表名

去重查詢:select DISTINCT 字段名 from 表名

起別名:

1.給字段起別名:select name as 姓名 from 表名

2.給表起別名:select name as 姓名 from 表名 as 學(xué)生表

三.基礎(chǔ)增刪改查

如果表存在就刪除,不存在就報(bào)錯(cuò):drop table 表名

如果表存在則刪除,如果不存在不會(huì)報(bào)錯(cuò):drop table if exists 表名

新增一條數(shù)據(jù):insert into 表名 values (,'',..)

增加指定的字段:insert into 表名(name) values(''),('')

刪除指定數(shù)據(jù):delete from 表名 where id=1

刪除表中全部數(shù)據(jù):delete from 表名

修改全部數(shù)據(jù):update 表名 set 字段名=值

修改指定數(shù)據(jù):update 表名 set 列名='',列名=值 where id=值

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容