SQL?????????????????
?????SimonLiang ???????[ 2016/8/26 11:10:34 ] ????????????? SQL
????????1----ALTER
???????д??????壺?????????my_foods????????????е??? ???????
????ALTER TABLE my_contacts????--??????
????ADD COLUMN id INT NOT NULL AUTO_INCREMENT FIRST????????--?μ? ?? id????????У?????????λ
????ADD PRIMARY KEY (id);????--???????????id?????????
?????????????????????????? PRIMARY KEY ?????
?????????????
????FIRST - --?? ??id ???????????????е????
????LAST -- ???? id ???????????е????
????SECOND -- ???? id ????? ???????
????AFTER(column1) -- ???? id ???? column1 ????
????BEFORE(column2) -- ???? id ???? column2 ???
?????????????
????ADD --- ???????????????——????????????????
????CHANGE--- ????????????е????????????????
????ALTER TABLE my_contacts
????CHANGE COLUMN breakfast morning_foods VARCHAR(20);??????-- ??????breakfast??? morning_foods ???μ?????? VARCHAR(20)
????MODIFY ---????????е????????????λ??
????ALTER TABLE my_contacts
????MODIFY COLUMN morning_foods AFTER id;
????DROP -- ???????????
????ALTER TABLE my_foods
????DROP COLUMN morning_foods;
????RENAME TO ----????????????
????ALTER TABLE my_contacts
????RENAME TO contacts;
????????2
????DELETE----???????л????????е??
????DELETE FROM my_foods --my_foods????????????????
????WHERE??breakfast = 'bread';
????DELETE ?? SELECT ????DELETE?????????????????????????????????е??????ж??????
?????????DELETE???????????????????????е????????????????????л?????У?????WHERE???????????WHERE????е?????????????SELECT????÷???????LIKE??IN??BETWEEN????????????????????????????????????????RDBMS???????С?
???????????????е???????????????DELETE??INSERT????????????????????????????????????????????????????????????????????????????????
????SELECT *FROM my_foods
????WHERE breakfast = 'milk';
????INSERT INTO my_foods
????VALUES('bread+milk');
????DELETE FROM my_foods
????WHERE breakfast = 'milk';
?????????????????????????????е??????????????????Σ?Ч??????UPDATE??????????????
????????3
????UPDATE---?????л????????е??????????WHERE???????е???????????????μ????
????UPDATE my_foods
????SET breakfast = 'bread'
?????????????μ???л?????У???ж????????WHERE??????
????UPDATE my_foods ---?????μ??
????SET breakfast = 'bread'????????--?????? ??????
????WHERE breakfast = 'milk';????????--??λ
????...
?????????SET ??????????????????????????????????Щ??????????????????
????UPDATE my_foods
????SET foods_num = foods_num +1
????WHERE breakfast IN ('bread'??'milk');
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11