刪表sql
㈠ 鍦⊿QL璇璦涓錛屽疄鐜板垹闄ゅ熀鏈琛ㄧ殑璇鍙ヤ負錛 錛
DROP TABLE錛孲QL璇璦涓鏁版嵁瀹氫箟鍔熻兘錛屽畾涔夊熀鏈琛ㄧ殑鍩烘湰鎿嶄綔鏈塁REATE TABLE銆丄LTER TABLE鍜孌ROP TABLE錛屽叾涓鍒犻櫎鍩烘湰琛ㄧ殑璇鍙ユ槸鐢盌ROP TABLE鏉ュ畬鎴愮殑銆
鍦⊿QL涓錛岀敤浜庡湪鏁版嵁搴撲腑鍒涘緩銆佷慨鏀瑰拰鍒犻櫎鍩烘湰琛ㄧ粨鏋勭殑鍛戒護鍒嗗埆鏄痠nsert銆乽pdate鍜宒elete鍛戒護銆傛坊鍔犮佷慨鏀瑰拰鍒犻櫎鍛戒護灞炰簬緇撴瀯鍖栨煡璇㈣璦鐨勬暟鎹鎿嶄綔璇璦錛岀敤鎴峰彲浠ラ氳繃榪欎簺鍛戒護瀹炵幇鏁版嵁搴撶殑鍩烘湰鎿嶄綔銆
鎵╁睍璧勬枡
sql鎵鎻愪緵鐨勫熀鏈鏁版嵁綾誨瀷錛(濡俕00100009b^)
鏁版嵁搴撶殑寤虹珛涓庡垹闄
(1)寤虹珛鏁版嵁搴擄細鏁版嵁搴撴槸涓涓鍖呮嫭浜嗗氫釜鍩烘湰琛ㄧ殑鏁版嵁闆錛屽叾璇鍙ユ牸寮忎負錛
CREATE DATABASE <鏁版嵁搴撳悕> 銆斿叾瀹冨弬鏁般
鍏朵腑錛<鏁版嵁搴撳悕>鍦ㄧ郴緇熶腑蹇呴』鏄鍞涓鐨勶紝涓嶈兘閲嶅嶏紝涓嶇劧灝嗗艱嚧鏁版嵁瀛樺彇澶辮銆
渚嬶細瑕佸緩絝嬮」鐩綆$悊鏁版嵁搴(xmmanage)錛屽叾璇鍙ュ簲涓猴細
CREATE DATABASE xmmanage
(2)鏁版嵁搴撶殑鍒犻櫎錛氬皢鏁版嵁搴撳強鍏跺叏閮ㄥ唴瀹逛粠緋葷粺涓鍒犻櫎銆
鍏惰鍙ユ牸寮忎負錛欴ROP DATABASE <鏁版嵁搴撳悕>
㈡ 鍒犻櫎琛ㄧ殑sql鍛戒護鏄浠涔
1銆丼QL璇璦涓錛屽垹闄や竴涓琛ㄧ殑鍛戒護鏄疍ROP錛屽緩絝嬩竴涓琛ㄧ殑鍛戒護鏄疌REATE錛屽硅〃榪涜屼慨鏀圭殑鍛戒護鏄疉LTER錛屽彟澶栬繕鏈夎〃涓鏁版嵁鐨勬彃鍏ワ紝鍒犻櫎錛屾煡璇㈠懡浠ゅ垎鍒涓篒NSERT錛孶PDATE鍜孲ELECT銆
2銆乨rop鏄鍒犻櫎鏁翠釜琛錛宒elete鏄鍒犻櫎琛ㄧ殑鍐呭廣
3銆乨rop璇鍙ョ殑浣滅敤錛氬垹闄ゅ唴瀹瑰拰瀹氫箟錛岄噴鏀劇┖闂達紝綆鍗曟潵璇村氨鏄鎶婃暣涓琛ㄥ幓鎺夈備互鍚庤佹柊澧炴暟鎹鏄涓嶅彲鑳界殑錛岄櫎闈炴柊澧炰竴涓琛ㄣ
4銆佸垹闄よ〃鏃墮渶瑕佹敞鎰忕殑浜嬮」錛氬傛灉鍒犻櫎搴旂敤琛ㄥ埆鍚嶏紝鍒檇elete 鍚庨潰涓瀹氳佹帴瀵瑰簲鐨勫埆鍚嶏紝鐒跺悗鍐嶆帴琛ㄥ悕錛屼笉鐒舵姤閿欍俤elete鍒犻櫎sql鍚庨潰涓嶅彲鎺ラ氶厤絎*錛屽嵆delete * from 錛岃繖鏍蜂細鎶ラ敊銆俤elete鍒犻櫎sql榛樿ょ殑榪斿洖鍊間負int鏁版嵁綾誨瀷錛屽綋鍒犻櫎涓鏉℃暟鎹鏃訛紝榪斿洖int鏁版嵁1錛屽綋鍒犻櫎num鏉℃暟鎹鏃訛紝鍒欒繑鍥瀒nt綾誨瀷num銆