MySQL???????????????
???????????? ???????[ 2016/12/26 10:46:16 ] ????????????? MySQL
????1????????????????
????MySQL?????????????????????????????????????????е???С????????????е????????????????????????????????????????????????????ε?????t?????С??
???????磬??????????????????????????????????CHAR(255)?????????????????????????????????VARCHAR???????????????????CHAR(6)????????????????????????????????????????????MEDIUMINT??????BIGIN????????????Ρ?
??????????????Ч??????????????????£???t?????????????NOTNULL?????????????в??????????????????NULL???
?????????Щ?????Σ?????“???”????“???”??????????????????ENUM??????????MySQL?У?ENUM????????????????????????????????????????????????????????????????????????????????????????????
????2??????????JOIN????????????(Sub-Queries)
????MySQL??4.1??????SQL??????????????????????SELECT???????????????е??????????????????????????????????????????С????磬?????????????????????????κζ??????????????????????????????????????н????з???????????ID??????????????????????????????????
????DELETEFROMcustomerinfo
????WHERECustomerIDNOTin(SELECTCustomerIDFROMsalesinfo)
????????????????????????????????????????????????SQL??????????????????????????????????д???????????????????Щ????£??????????????Ч????????JOIN??..????????磬?????????????????ж??????????????????????????????????????
????SELECT*FROMcustomerinfo
????WHERECustomerIDNOTin(SELECTCustomerIDFROMsalesinfo)
???????????????JOIN??..?????????????????????????????????salesinfo???ж?CustomerID??????????????????????????????£?
????SELECT*FROMcustomerinfo
????LEFTJOINsalesinfoONcustomerinfo.CustomerID=salesinfo.CustomerID
????WHEREsalesinfo.CustomerIDISNULL
?????????JOIN??..????????Ч???Щ???????MySQL???????????д??????????????????????????????????????????
????3?????????(UNION)????????????????????
????MySQL??4.0??汾??????union??????????????????????????????????select???????????????С????????????????????????????????????????????????????Ч?????union????????????????????????UNION???????????select?????????????????????????????select????е?????????????????????????????????UNION??????
????SELECTName??PhoneFROMclientUNION
????SELECTName??BirthDateFROMauthorUNION
????SELECTName??SupplierFROMproduct
????4??????
????????????????????????Sub-Queries?????????JOIN?????????UNION??????????????????????????????е???????????????????????????????SQL??????????????????????????????е???????????????????????????????£???????????е???????????г??????????????????????ò????????????????£??????????????????????????????У????????????????????????????г?????o???????????????????????????????е?????????????????????????????????????????????????е???????????????????????????????????????????????????????????????????????????仰??????????????????????????????????????????BEGIN?????????COMMIT?????????????????????SQL?????????????ROLLBACK?????????????????BEGIN???????????
????BEGIN; INSERTINTOsalesinfoSETCustomerID=14;UPDATEinventorySETQuantity=11WHEREitem='book';COMMIT;
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????5????????
??????????????????????????????????????????????????????????????????????????????????????????????С?????????????е?????У???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????г???????????????????????????????????????????????????????????????????????
???????????Щ??????????????????????????????????????????????????????????????????????????????????????
????LOCKTABLEinventoryWRITESELECTQuantityFROMinventoryWHEREItem='book';
????...
????UPDATEinventorySETQuantity=11WHEREItem='book';UNLOCKTABLES
?????????????????select??????????????????Щ??????update??佫??????μ????С???????WRITE??????LOCKTABLE??????????UNLOCKTABLES??????????????????????????????inventory???в????????????????????
??????
???·???
??????????????????
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