萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> SQL DELETE 語句

SQL DELETE 語句

DELETE 語句
DELETE 語句用於刪除表中的行。

語法
DELETE FROM 表名稱 WHERE 列名稱 = 值Person:
LastName FirstName Address City
Gates Bill Xuanwumen 10 Beijing
Wilson Fred Zhongshan 23 Nanjing
刪除某行
"Fred Wilson" 會被刪除:

DELETE FROM Person WHERE LastName = 'Wilson' 結果:
LastName FirstName Address City
Gates Bill Xuanwumen 10 Beijing
刪除所有行
可以在不刪除表的情況下刪除所有的行。這意味著表的結構、屬性和索引都是完整的:

DELETE FROM table_name或者:

DELETE * FROM table_name

教程二

語法
DELETE FROM table_name
WHERE column_name = some_value
Person:
LastName FirstName Address City
Nilsen    Fred    Kirkegt 56    Stavanger
Rasmussen  Nina    Stien 12     Stavanger

刪除某行
"Nina Rasmussen"會被刪除:

DELETE FROM Person WHERE LastName = 'Rasmussen'
結果:
LastName FirstName Address City
Nilsen    Fred    Kirkegt 56    Stavanger

刪除所有行
可以在不刪除表的情況下刪除所有的行。這意味著表的結構、屬性和索引都是完整的:

copyright © 萬盛學電腦網 all rights reserved