MySQL基本語法

利用MySQL創(chuàng)建數(shù)據(jù)表

查看創(chuàng)建表:show tables;

查看創(chuàng)建表基本結(jié)構(gòu)語句:describe 表的名字;

查看創(chuàng)建表中信息的結(jié)構(gòu)語句:show create table 表的名字;

修改表:alter table 表的名字-----(用于更改原有表的結(jié)構(gòu))

增加表的字段:add address 增加的字段;(添加操作后,也可以執(zhí)行“describe?student;”命令查看結(jié)果。)

修改表名:alter table 舊名字 rename to 新名字;

刪除字段:alter table 表名字 drop 表中要刪除的字段;

刪除數(shù)據(jù)庫表:drop table 表的名字;(代碼運行成功,從數(shù)據(jù)庫中刪除表,在執(zhí)行代碼之前,先用desc語句查看是否存在表,以便與刪除后進(jìn)行對比。)

表記錄的修改:>table 舊內(nèi)容 set 新內(nèi)容? ? ?->where 舊內(nèi)容(用update..set..命令可以修改一個表的數(shù)據(jù))

mysql>update score set daily=80

? ? ? ? ?-> where studentno='1813722508'&& courseno='c08106';

mysql> select * form score

? ? ? ? -> where studentno='1813722508'&& courseno='c08106';

mysql>update student01 set entrance=student01*1.08 where?entrance<700;

表記錄的刪除:delete from 舊內(nèi)容 where 滿足的條件(利用?delete...from...語句可以從單個表中刪除指定表數(shù)據(jù))

mysql>delete from student01 where?entrance<750;

mysql>delete from student01 order by?entrance limit 2;

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

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