日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

mysql 插入删除操作_MySQL——增删改操作

發布時間:2023/11/27 生活经验 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 插入删除操作_MySQL——增删改操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

插入語句

一次插入操作只插入一行數據

insert into [tablename](listname1,listname2,......) values (value1,value2,......);

/* 插入一條數據 */

insert into t_students(id,name,age) values(10,'敏敏',24);

/* 插入多條數據MySQL特有的 */

insert into t_students(id,name,age) values(10,'YY',24),(10,'MM',24),(10,'HH',24);

/* 插入查詢結果 */

insert into t_students(name) select name from t_students;

更新操作

不能更改主鍵!!!

update [tablename] set [listname]=value where [條件];

/* 將年齡大于25的改為18 */

update t_students set age=18 where age >= 25;

如果省略where,則整個表的數據都會被修改

刪除操作

delete from [tablename] where [條件];

/* 刪除年齡為18的數據 */

如果省略where,則整個表的數據都會被刪除!!!

添加列

alter table [tablename] add [listname] [數據類型] after [listname插入位置]

/* 在表的最后追加列 address */

alter table students add address char(60);

/* 在名為 age 的列后插入列 birthday */

alter table students add birthday date after age;

修改列

alter table [tablename] change [listname] [newlistname] [新數據類型];

/* 將表 tel 列改名為 telphone */

alter table students change tel telphone char(13) default "-";

/*將 name 列的數據類型改為 char(16) */

alter table students change name name char(16) not null;

/* 當字段只包含空值時,類型大小都可以修改 */

alter table [tablename] modify [listname] [數據類型];

刪除列

alter table [tablename] drop [listname];

/* 刪除 birthday 列 */

alter table students drop birthday;

重命名表

alter table [tablename] rename [newtablename];

/* 重命名 students 表為 workmates */

alter table students rename workmates;

總結

以上是生活随笔為你收集整理的mysql 插入删除操作_MySQL——增删改操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。