插入數(shù)據(jù)
insert into Student (Sid,Sname,Sage,Ssex)
values
(01,'張三',15,'男');
[Mysql 刪除數(shù)據(jù)表的三種方式詳解
用法:
1酥馍、當(dāng)你不再需要該表時(shí), 用 drop;
2阅酪、當(dāng)你仍要保留該表旨袒,但要?jiǎng)h除所有記錄時(shí), 用 truncate;
3术辐、當(dāng)你要?jiǎng)h除部分記錄或者有可能會(huì)后悔的話(huà)砚尽, 用 delete。
刪除程度可從強(qiáng)到弱如下排列:
-
drop table tb;
drop 是直接將表格刪除辉词,無(wú)法找回必孤。例如刪除 user 表:
drop table user;
-
truncate (table) tb;
truncate 是刪除表中所有數(shù)據(jù),但不能與where一起使用瑞躺;
TRUNCATE TABLE user;
3. delete from tb (where);
delete 也是刪除表中數(shù)據(jù)敷搪,但可以與where連用,刪除特定行幢哨;
-- 刪除表中所有數(shù)據(jù)
delete from user;
-- 刪除指定行
delete from user where username ='Tom';