??????3??????????
?????????????????????????????п??????????????????????????????????
????CREATE TABLE mytable( ID INT NOT NULL?? username VARCHAR(16) NOT NULL??
????PRIMARY KEY(ID) );
?????????????? ALTER ???????????????????????????
??????4?????????
??????????????????????????????????????????Σ?
????CREATE TABLE mytable( ID INT NOT NULL?? username VARCHAR(16) NOT NULL??
????city VARCHAR(50) NOT NULL?? age INT NOT NULL );
?????????????MySQL??Ч??????????????????????? name?? city?? age?????????????
????ALTER TABLE mytable ADD INDEX name_city_age (name(10)??city??age);
???????????usernname????? 16????????
????10??????????????????????????????10???????????????????????????????????????С?????INSERT?????????
????????????
????usernname??city??age?????????????????????3???????????????????????????????Ч?????????????????????????????????????????????????????MySQL?????????е????????????????Ч????????????
???????????????????????????????????????????????????????
????usernname??city??age usernname??city usernname ??????
????city??age???????????????????????MySQL???????“????”??????????????????????????????????????????????е?????????????????????????????SQL?????????????????
????SELECT * FROM mytable WHREE username="admin" AND city="???" SELECT * FROM
????mytable WHREE username="admin"
?????????漸???????????
????SELECT * FROM mytable WHREE age=20 AND city="???" SELECT * FROM mytable WHREE
????city="???"
??????5???????????????
??????????????????????????????????????????????????????????????????????WHERE??JOIN?г??????????????????????????????????MySQL???<??<=??=??>??>=??BETWEEN??IN??????Щ????LIKE???????????????磺
????SELECT t.Name FROM mytable t LEFT JOIN mytable m ON t.Name=m.username
????WHERE m.age=20 AND m.city='???'
????????????city??age??????????????mytable???userame?????????JOIN????У???ж?????????????????
?????????????Щ????LIKE???軌???????????????????%??_???????????MySQL??????????????????????????????
????SELECT * FROM mytable WHERE username like'admin%'
???????????????
????SELECT * FROM mytable WHEREt Name like'%admin'
?????????????LIKE??????????????
??????6??????????????
???????涼????????????????????????????????????????á????????????????????
????????????????????????????????????±?????????????INSERT??UPDATE??DELETE????????±????MySQL?????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????Ч?????????????????MySQL?д????????????????????о????????????????????????
??????7??????????????????
?????????????????????Щ????????????
???????????????????NULL?????
?????????а?????NULL????????????????????У?????????????????к???NULL??????????ж???????????????Ч?????????????????????????????ε??????NULL??
??????????????
????????н???????????????????????????????????磬????????CHAR(255)???У???????10????20???????????????Ω?????????????????н??????????????????????????????????????????????I/O??????
????????????????
????MySQL??????????????????????where?????????????????????????order
????by?е???????????????????????????????????????????????2?????????????????????????????е????????????????Щ?д?????????????
??????like??????
???????????2????????like?????????????ò????????????????????like “%aaa%” ?????????????like
????“aaa%”?????????????
?????????????????????
????select * from users where YEAR(adddate)<2007;
?????????????????????????????????Ч???????????裬????????????
????select * from users where adddate<‘2007-01-01’;
??????????NOT IN??<>????