1. 程式人生 > >sql 基礎增刪改查語句

sql 基礎增刪改查語句

1.1【插入單行】
insert [into] <表名> (列名) values (列值)
例:insert into Strdents (姓名,性別,出生日期) values ('開心朋朋','男','1980/6/15')


1.2【將現有表資料新增到一個已有表】
insert into <已有的新表> (列名) select <原表列名> from <原表名>
例:insert into tongxunlu ('姓名','地址','電子郵件')
select name,address,email
from Strdents

2刪

2.1【刪除<滿足條件的>行】
delete from <表名> [where <刪除條件>]
例:delete from a where name='開心朋朋'(刪除表a中列值為開心朋朋的行)


2.2【刪除整個表】
truncate table <表名>
truncate table tongxunlu
注意:刪除表的所有行,但表的結構、列、約束、索引等不會被刪除;不能用語有外建約束引用的表

3改

update <表名> set <列名=更新值> [where <更新條件>]
例:update tongxunlu set 年齡=18 where 姓名='藍色小名'