VTYS 2012 Mehmet Emin KORKUSUZ Ders - 06
DCL DATA CONTROL LANGUAGE
CREATE USER CREATE USER user_specification [, user_specification] ... user_specification: user [IDENTIFIED BY [PASSWORD] 'password' | IDENTIFIED WITH auth_plugin [AS 'auth_string'] ]
CREATE USER CREATE USER ‘emin'@'localhost' IDENTIFIED BY ‘sifre'; CREATE USER ‘superadmin’@’%’ IDENTIFIED ‘zorsifre’; CREATE USER ‘kullanici’@’%.balikesir.edu.tr’ IDENTIFIED ‘sifre’; INSERT INTO user (host,user,password) VALUES('localhost',‘kullanici',PASSWORD(‘sifre’));
DROP USER DROP USER ‘emin’@‘localhost’;
RENAME USER RENAME USER ‘emin’@'localhost' TO ‘mek'@'127.0.0.1';
SET PASSWORD SET PASSWORD FOR ‘can'@'%.edu.tr' = PASSWORD(‘sifre'); UPDATE mysql.user SET Password=PASSWORD(‘sifre') WHERE User=‘can' AND Host='%.edu.tr'; FLUSH PRIVILEGES; GRANT USAGE ON *.* TO ‘can'@'%.edu.tr' IDENTIFIED BY ‘sifre';
Grant Revoke YETKİLENDİRME Kullanıcıya yetki vermek. kullanıcıyı yetkilendirmek Grant Revoke Kullanıcının yetkilerini kaldırmak
GRANT priv_type [(column_list)] [, priv_type [(column_list)]] GRANT priv_type [(column_list)] [, priv_type [(column_list)]] ... ON [object_type] priv_level TO user_specification [, user_specification] ... [REQUIRE {NONE | ssl_option [[AND] ssl_option] ...}] [WITH with_option ...]
GRANT PROXY ON user_specification TO user_specification [, user_specification] ... [WITH GRANT OPTION]
object_type: TABLE | FUNCTION | PROCEDURE priv_level:. |. | db_name object_type: TABLE | FUNCTION | PROCEDURE priv_level: * | *.* | db_name.* | db_name.tbl_name | tbl_name | db_name.routine_name
with_option: GRANT OPTION | MAX_QUERIES_PER_HOUR count | MAX_UPDATES_PER_HOUR count | MAX_CONNECTIONS_PER_HOUR count | MAX_USER_CONNECTIONS count
Verilebilecek Yetkiler GRANT ALL Select İnsert Drop Verilebilecek Yetkiler Update Delete Create USAGE
GRANT grant all on * to dilek identified by 'sifrem' Genel Kullanımı GRANT YETKILER ON VERITABANI_ADI TO KULLANICI IDENTIFIED BY Istenen_Sifre ; grant all on * to dilek identified by 'sifrem' with grant option;
GRANT CREATE DATABASE, CREATE TABLE TO kul1,kul2; Örnek: Birden çok kullanıcıya hem veri tabanı hem de tablo oluşturma izni vermek istersek; GRANT CREATE DATABASE, CREATE TABLE TO kul1,kul2;
GRANT Eğer hosttan iletişimi kontrol etmek istiyorsak; GRANT YETKILER ON VERITABANI_ADI TO ‘KULLANICI’@’Host Adı/ID Numarası’ IDENTIFIED BY Istenen_Sifre ; Örneğin; grant all on * to 'dilek'@'%' identified by 'bote';
GRANT Örnek: dilek kullanicisina deneme veritabani uzerinde sifre1 parolasi ile 192.168.1.37 ip_adresli makineden veritabanı oluşturma izni ile baglanabilmesi icin; GRANT CREATE DATABASE ON deneme.* TO 'dilek'@'192.168.1.37' IDENTIFIED BY 'sifre1';
GRANT CREATE USER ‘can'@'localhost' IDENTIFIED BY ‘sifre'; GRANT ALL ON db1.* TO ‘can'@'localhost'; GRANT SELECT ON db2.ogrenci TO ‘can'@'localhost'; GRANT USAGE ON *.* TO‘can'@'localhost' WITH MAX_QUERIES_PER_HOUR 90;
GRANT GRANT ALL ON *.* TO 'someuser'@'somehost'; GRANT SELECT, INSERT ON *.* TO 'someuser'@'somehost'; GRANT ALL ON mydb.* TO 'someuser'@'somehost'; GRANT SELECT, INSERT ON mydb.* TO 'someuser'@'somehost';
GRANT GRANT ALL ON mydb.mytbl TO 'someuser'@'somehost'; GRANT SELECT, INSERT ON mydb.mytbl TO 'someuser'@'somehost'; GRANT SELECT (col1), INSERT (col1,col2) ON mydb.mytbl TO 'someuser'@'somehost'; GRANT CREATE ROUTINE ON mydb.* TO 'someuser'@'somehost'; GRANT EXECUTE ON PROCEDURE mydb.myproc TO 'someuser'@'somehost';
GRANT SSL GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost' IDENTIFIED BY 'goodsecret' REQUIRE SSL;
REVOKE REVOKE FROM user [, user] ... priv_type [(column_list)] [, priv_type [(column_list)]] ... ON [object_type] priv_level FROM user [, user] ... REVOKE ALL PRIVILEGES, GRANT OPTION REVOKE PROXY ON user FROM user [, user] …
REVOKE REVOKE INSERT ON *.* FROM ‘CAN'@'localhost'; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...
SELECT
DISTINCT Tekrarlı sonuçları eler. Group by gibi çalışır.
ORDER BY Sonuçları sıralamak için kullanılır. ASC artan sıralama DESC azalan sıralama SELECT college, region, seed FROM tournament ORDER BY region, seed;
WHERE Sorguya şart ekler. Select * from ogrenci where yas<20; Select * from ogrenci where yas<20 and boy>150; Select * from ogrenci where yas<20 and boy>150 or isim like ‘a%’;
WHERE SELECT t1.name, t2.salary FROM employee AS t1, info AS t2 WHERE t1.name = t2.name; SELECT t1.name, t2.salary FROM employee t1, info t2 WHERE t1.name = t2.name;
IN Bir alanın değeri bir küme içinden herhangi bir değere eşitse sonucu gösterir. SELECT * FROM adres WHERE ülkekod IN (‘TR’,‘US’,‘UK’,‘GB’,‘CN’)
BETWEEN … AND … İki değer arasını göstermenin kısa yoludur. SELECT * FROM ogrenci WHERE vize>= 90 AND vize<= 100; SELECT * FROM ogrenci WHERE vize BETWEEN 90 AND 100;
LIKE % _ [harf] [^harf] [A-Z]
LIKE SELECT * FROM `haber` WHERE baslik like '%arama%';
LIKE SELECT * FROM maas WHERE kst LIKE '%1740 %' OR kst LIKE '%1938 %' OR kst LIKE '%1940 %‘; SELECT * from maas where kst REGEXP '1740|1938|1940';
CAST | CONVERT Tip dönüşümü yapmak için kullanılır. SELECT CONVERT('abc' USING utf8); SELECT 'A' LIKE CONVERT(blob_col USING latin1) FROM tbl_name; SET @str = BINARY 'New York'; SELECT LOWER(@str), LOWER(CONVERT(@str USING latin1));
SELECT CAST(1-2 AS UNSIGNED) ; 18446744073709551615 SELECT CAST(CAST(1-2 AS UNSIGNED) AS SIGNED); -1