{"id":2176,"date":"2017-05-28T13:33:31","date_gmt":"2017-05-28T13:33:31","guid":{"rendered":"http:\/\/www.kodcafe.com\/?p=2176"},"modified":"2020-10-23T00:56:29","modified_gmt":"2020-10-22T21:56:29","slug":"mysql-de-sql-komutlari","status":"publish","type":"post","link":"https:\/\/www.kodcafe.com\/?p=2176","title":{"rendered":"Mysql de SQL Komutlar\u0131"},"content":{"rendered":"<p>\u25cf CREATE DATABASE &#8211; creates a new database<br \/>\n\u25cf CREATE TABLE &#8211; creates a new table<br \/>\n\u25cf INSERT INTO &#8211; inserts new data into a database<br \/>\n\u25cf UPDATE &#8211; updates data in a database<br \/>\n\u25cf DELETE &#8211; deletes data from a database<br \/>\n\u25cf ALTER DATABASE &#8211; modifies a database<br \/>\n\u25cf ALTER TABLE &#8211; modifies a table<br \/>\n\u25cf DROP TABLE &#8211; deletes a table<br \/>\n\u25cf CREATE INDEX &#8211; creates an index (search key)<br \/>\n\u25cf SELECT &#8211; extracts data from a database<\/p>\n<p style=\"text-align: center;\"><strong><span style=\"color: #ff0000;\">&nbsp;CREATE DATABASE &#8211; YEN\u0130 B\u0130R VER\u0130 TABANI OLU\u015eTURMAK<\/span><\/strong><\/p>\n<p><span style=\"color: #3366ff;\">CREATE DATABASE Bilgi;<\/span> &nbsp;\u201c Bilgi veri taban\u0131 olu\u015fturma komutu\u201d<br \/>\n<!--more--><\/p>\n<p><span style=\"color: #3366ff;\">CREATE DATABASE if not exists Bilgi;<\/span> \u201c E\u011fer b\u00f6yle bir veri taban\u0131 yoksa olu\u015fturma komutu\u201d<\/p>\n<p><span style=\"color: #3366ff;\">CREATE DATABASE if not exists Bilgi<\/span><br \/>\n<span style=\"color: #3366ff;\"> char set utf8<\/span><br \/>\n<span style=\"color: #3366ff;\"> collate utf8_turkish_ci;<\/span><\/p>\n<p>\u201c burada veri taban\u0131m\u0131z\u0131n turkce karakter sorunu ya\u015famamas\u0131 i\u00e7in karakter kodlamas\u0131n\u0131 T\u00fcrk\u00e7e karakteri destekleyen utf 8 ayarlam\u0131\u015f olduk. \u201d<\/p>\n<p>\u201cturk\u00e7e karakter destekleyen yeni Latin 5 ( ISO-8859-9 ) se\u00e7ebiliriz.<\/p>\n<p>E\u011fer hangi karakter setleri mysql var kontrol etmek istiyorsak<\/p>\n<p><span style=\"color: #3366ff;\">SHOW CHARACTER SET;<\/span> \u201cmysql sisteminde karakter setlerini listeler grup halindedir\u201d<br \/>\n<span style=\"color: #3366ff;\">SET NAMES UTF8;<\/span> sonradan karakter setimizi set names komutu ile ayarlayabiliriz.<br \/>\n<span style=\"color: #3366ff;\">show collation;<\/span> \u201c desteklene collate yani collation karakter setlerini g\u00f6sterir\u201d<\/p>\n<p><strong><span style=\"color: #ff0000;\">CREATE TABLE \u2013 Yeni bir tablo olu\u015fturmak<\/span><\/strong><\/p>\n<p><span style=\"color: #3366ff;\">create table deneme (<\/span><br \/>\n<span style=\"color: #3366ff;\"> id int auto_increment primary key, \u201cint olacak otomatik artacak tek olacak\u201d<\/span><br \/>\n<span style=\"color: #3366ff;\"> ad char(50),<\/span><br \/>\n<span style=\"color: #3366ff;\"> soyad char(100),<\/span><br \/>\n<span style=\"color: #3366ff;\"> sinav int);<\/span><\/p>\n<p><strong>&nbsp;&nbsp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">CREATE TABLE `iller` (<\/span><br \/>\n<span style=\"color: #3366ff;\"> `id_il` int(11) NOT NULL unique,,<\/span><br \/>\n<span style=\"color: #3366ff;\"> `il_adi` varchar(30) COLLATE utf8_turkish_ci DEFAULT NULL,<\/span><br \/>\n<span style=\"color: #3366ff;\"> `plaka` tinyint(4) DEFAULT NULL<\/span><br \/>\n<span style=\"color: #3366ff;\"> ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci;<\/span><\/p>\n<p>Not..: \u201cENGINE mysql arama motorudur.\u201d<br \/>\nUnique : numara sadece tek olsun. Kimseye verilmesin.<\/p>\n<p style=\"text-align: center;\"><span style=\"color: #ff0000;\"><strong>INSERT INTO \u2013 VER\u0130 G\u0130R\u0130\u015e\u0130<\/strong><\/span><\/p>\n<p><span style=\"color: #3366ff;\">insert into ogrenci (id,isim,numara,vize,final)<\/span><br \/>\n<span style=\"color: #3366ff;\"> values(null,&#8217;nuri can&#8217;,&#8217;201710050052&#8242;,10,80),<\/span><\/p>\n<p>Bu \u00f6rnekte ogrenci tablosu i\u00e7indeki belirtilen isimlere belirtilen de\u011ferleri tek tek veya altaki gibi birden fazla veri giri\u015fi yap\u0131labilir.<\/p>\n<p><span style=\"color: #3366ff;\">insert into ogrenci(id,isim,numara,vize,final)<\/span><br \/>\n<span style=\"color: #3366ff;\"> values(null,&#8217;nuri can&#8217;,&#8217;201710050053&#8242;,10,80),<\/span><br \/>\n<span style=\"color: #3366ff;\"> (null,&#8217;veli \u00e7am&#8217;,&#8217;201596235154&#8242;,50,90);<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"color: #ff0000;\">UPDATE \u2013 G\u00fcncelleme komutu<\/span><\/p>\n<p><span style=\"color: #3366ff;\">update ogrenci set ayakno=42.5 where id=1; <\/span>\/*id 1 ayakno g\u00fcncelle*\/<\/p>\n<p><span style=\"color: #3366ff;\">update dene set soyad=&#8221;cem&#8221; , sinav=50 where id=5; &nbsp;<\/span>id si 5 olan soyad ve sinav notunu g\u00fcncelledik.<\/p>\n<p>NOT: update ve delete komutunu kullanacak iseniz workbench bu i\u015flemi yapman\u0131z gerekmektedir.<br \/>\n\/*edit refences workbench refenrans da sql safe updates \u00e7elti\u011fi kald\u0131r*\/<\/p>\n<p style=\"text-align: center;\"><span style=\"color: #ff0000;\">DELETE \u2013 Silme komutu<\/span><\/p>\n<p><span style=\"color: #3366ff;\">UPDATE FROM ogrenci WHERE id=5;<\/span> 5 numarali id yi siler<br \/>\n<span style=\"color: #3366ff;\">UPDATE FROM ogrenci WHERE soyad=\u2019can\u2019;<\/span> soyad\u0131 can olanlar\u0131 siler<\/p>\n<p><span style=\"color: #3366ff;\">UPDATE FROM ogrenci WHERE sinav&lt;50;<\/span> sinav notu 50 den a\u015fa\u011f\u0131 olanlar sil;<\/p>\n<p>NOT: update ve delete komutunu kullanacak iseniz workbench bu i\u015flemi yapman\u0131z gerekmektedir.<br \/>\n\/*edit refences workbench refenrans da sql safe updates \u00e7elti\u011fi kald\u0131r*\/<\/p>\n<p><span style=\"color: #ff0000;\"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ALTER DATABASE \u2013 VER\u0130 TABANINI G\u00dcNCELLE<\/strong><\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"color: #ff0000;\">ALTER TABLE \u2013 TABLO G\u00dcNCELLE<\/span><\/p>\n<p><span style=\"color: #3366ff;\">ALTER TABLE ogrenci ADD COLUMN vize int(2) AFTER sinav;<\/span> ogrenci tablosunda sinav kolonundan sonra vize alan\u0131 olu\u015ftur. Tipide integer tipli de\u011fi\u015fken olsun<\/p>\n<p><span style=\"color: #3366ff;\">Alter table ogrenci modify vize varchar(10) float;<\/span> vize isimli alan\u0131n tipini varchar tipinde de\u011fi\u015ftirdim<br \/>\n<span style=\"color: #3366ff;\">Alter table ogrenci drop column vize;<\/span> vize isimli colonu siler<\/p>\n<p style=\"text-align: center;\"><span style=\"color: #ff0000;\">DROP TABLE \u2013 tabloyu silmek<\/span><\/p>\n<p><span style=\"color: #3366ff;\">DROP TABLE yeni;<\/span> yeni isimli bir tablomuz vard\u0131. Bu tablomuzu drop table komutu ile sildik<\/p>\n<p><span style=\"color: #3366ff;\">TRUNCATE OGRENC\u0130<\/span>; ogrenci tablosu i\u00e7eri\u011fini siler . tabloyu komple silmez<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u25cf CREATE DATABASE &#8211; creates a new database \u25cf CREATE TABLE &#8211; creates a new table \u25cf INSERT INTO &#8211; inserts new data into a database \u25cf UPDATE &#8211; updates data in a database \u25cf DELETE &#8211; deletes data from a database \u25cf ALTER DATABASE &#8211; modifies a database \u25cf ALTER TABLE &#8211; modifies a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2258,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[285,406,488],"class_list":["post-2176","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-mysql-komutlari","tag-sql-komutlari","tag-workbench-komutlari"],"_links":{"self":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts\/2176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2176"}],"version-history":[{"count":1,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts\/2176\/revisions"}],"predecessor-version":[{"id":2261,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts\/2176\/revisions\/2261"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/media\/2258"}],"wp:attachment":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}