MySql(2)-新增-修改-刪除
阿新 • • 發佈:2022-05-29
--插入語句(新增) --INSERT INTO 表名 ([欄位名1,欄位名2]) VALUES ('值'),('值'),('值') INSERT INTO `student` (`name`) VALUES ('一葉知秋') INSERT INTO student (`id`) VALUES (3) INSERT INTO student (`id` ,`name`,`pwd`) VALUES (2,'夜雨聲煩','aaaaa') INSERT INTO student (`sex`) VALUES ('男'),('男') INSERT INTO student VALUES (6,'大漠孤煙','bbbbbb','男','1999-09-02','[email protected]')
--修改 UPDATE --UPDATE 表名 SET colnum_name = VALUE,[colnum_name = VALUE] WHERE [條件] --不指定條件的情況下,會改動所有的資訊 UPDATE student SET `name` = '一槍穿雲' WHERE id=3 UPDATE student SET `name` = '沐雨橙風',`sex` = '女'WHERE id=4 UPDATE student SET `name` = '索克薩爾' WHERE pwd=123456AND sex='男'
<>和這個!=都是不等於的意思
--刪除 DELETE DELETE FROM student WHERE id=1 --DELETE 與 TRUNCATE 的區別 DELETE FROM student --不會影響自增 TRUNCATE TABLE `student` --自增歸零