sql甯哥敤鍛戒护
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql甯哥敤鍛戒护相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e8%ae%b0%e5%bd%95' title='璁板綍'>璁板綍
淇敼 ble 鎸囦护 lock ike drop href 甯哥敤DDL 鏁版嵁搴撴ā寮忓畾涔夎瑷€(Data Definition Language)锛岃礋璐f暟鎹粨鏋勫畾涔変笌鏁版嵁搴撳璞″畾涔夌殑璇█銆?/p>
鍒涘缓鏁版嵁搴?CREATE DATABASE
鍒涘缓鏁版嵁搴撹〃鏍?CREATE TABLE
淇敼鏁版嵁搴撹〃鏍?ALTER TABLE
鍒犻櫎鏁版嵁搴撹〃鏍?DROP TABLE
e.g 灏嗘暟鎹〃emp鏀瑰悕涓篹mpdep
alter table emp rename empdep;
DML 鏁版嵁鎿嶇旱璇█锛圖ata Manipulation Language锛?/p>
select 妫€绱? insert 鎻掑叆
update 鏇存柊
delete
e.g UPDATE 璇彞鐢ㄤ簬鏇存柊琛ㄤ腑鐨勮褰?UPDATE user
SET username=鈥榬obot鈥? password=鈥榬obot鈥?WHERE usename=鈥榬obot鈥?
e.g 鏌ヨ澶氬垪
SELECT prod_id, prod_name, prod_price
FROM products;
e.g 鏌ヨ鎵€鏈夊垪
SELECT *
FROM products;
DCL 鏁版嵁鎺у埗璇█ (Data Control Language锛夋槸涓€绉嶅彲瀵规暟鎹闂潈杩涜鎺у埗鐨勬寚浠?/p>
commit
rollback
grant
revoke
鎺堜簣鏉冮檺
GRANT SELECT, INSERT ON *.* TO myuser;
鍒犻櫎鏉冮檺
REVOKE SELECT, INSERT ON *.* FROM myuser;
ON *.* 鍗虫墍鏈夋暟鎹簱閮芥湁鏁堢殑鎰忔€?/code>
IN 鍜?BETWEEN
- IN 鎿嶄綔绗﹀湪 WHERE 瀛愬彞涓娇鐢紝浣滅敤鏄湪鎸囧畾鐨勫嚑涓壒瀹氬€间腑浠婚€変竴涓€笺€?/li>
- BETWEEN 鎿嶄綔绗﹀湪 WHERE 瀛愬彞涓娇鐢紝浣滅敤鏄€夊彇浠嬩簬鏌愪釜鑼冨洿鍐呯殑鍊笺€?/li>
IN 绀轰緥
SELECT *
FROM products
WHERE vend_id IN (鈥楧LL01鈥? 鈥楤RS01鈥?;
BETWEEN 绀轰緥
SELECT *
FROM products
WHERE prod_price BETWEEN 3 AND 5;
LIKE鎿嶄綔绗﹀湪 WHERE 瀛愬彞涓娇鐢紝瀛楁鏄枃鏈€兼椂鎵嶄娇鐢?LIKE銆?br>
LIKE 鏀寔涓や釜閫氶厤绗﹀尮閰嶉€夐」锛? 鍜?銆?br>
% 琛ㄧず浠讳綍瀛楃鍑虹幇浠绘剰娆℃暟銆?/em> 琛ㄧず浠讳綍瀛楃鍑虹幇涓€娆°€?/p>
% 绀轰緥SELECT prod_id, prod_name, prod_price
FROM products
WHERE prod_name LIKE 鈥?bean bag%鈥?
以上是关于sql甯哥敤鍛戒护的主要内容,如果未能解决你的问题,请参考以下文章