DML Data Manipulation Language
Kategori SQL
-------------------------- DML (Data Manipulation Language)------------------------
-- Select
-- Insert
-- Update
-- Delete
Sql’e dair bazı select sorgulamalarına başlayalım. Bir takım fonksiyonları da kullanacağız.
İlerleyen zamanlarda fonksiyonlara yönelik detaylı çalışmalarımız tekrardan olacak. Şimdi SQL
Server Management Studio’yu açın ve Sql’lerin keyfini çıkartın. için
İyi Eğlenceler.
-- ******* SELECT *****
select 44
44
select 4+5
9
select 44, 4+5
44 | 9
select 5 * 10 as Sonuc
Sonuc
50
select 4*5 as CARPIM, 4+5 as TOPLAM
select 'Hizlan' as ISIM
ISIM
Hizlan
select 'Hizlan' as ISIM, 'ERPAK' as SOYAD, '1979' as [7+9] (SQL SERVER)
ISIM SOYAD 7+9
Hizlan ERPAK 1979
-- Temel Metinsel işlemler (String Fonksiyonlar)
select UPPER('Yazilimcoplugu') as İsim;
YAZİLİMCOPLUGU
select UPPER('hizlan') as isim, UPPER('erpak') as Soyad;
İsim Soyad
HİZLAN ERPAK
select lower('HiZlAn') as [lower('İsim')]
-- MSSQL buyuk ve kucuk harf duyarlı değildir.
select SUBSTRING('Yazilim Coplugu',3,2) as sonuc;
sonuc
zi
CARPIM TOPLAM
20 9
select LEN('Yazilim Coplugu') as sonuc;
sonuc
15
select LEN('Yazilimcoplugu') as sonuc;
sonuc
14
select SUBSTRING('Yazilimcoplugu',2,LEN('Yazilimcoplugu')-2) as sonuc;
sonuc
azilimcoplug
select ' Yazilim Coplugu ' as sonuc;
sonuc
Yazilim
Coplugu
select LTRIM(' Yazilim Coplugu') as sonuc;
sonuc
Yazilim Coplugu
select RTRIM(' Yazilim Coplugu ') as sonuc;
sonuc
Yazilim Coplugu
select LTRIM(RTRIM(' Yazilim Coplugu ')) as sonuc;
sonuc
Yazilim Coplugu
Select REPLACE('Yazilim Coplugu',' ','Sistem') as sonuc
sonuc
YazilimSistemCoplugu
Select LEFT('Yazilim Coplugu',3) as sonuc;
sonuc
Yaz
select RIGHT('Yazilim Coplugu',4) as sonuc;
sonuc
lugu
select
Left(Right(LOWER(REVERSE(UPPER(LTRIM(SUBSTRING('Yazilimcoplugu',5
,LEN('Yazilimcoplugu')-5))))),1),2)+'Database' as İsim;
İsim
lDatabase
-- Ne kelimesi olursa olsun sondan 3. harf gelsin
select Substring(Upper('Fenerbahçe'),Len('Fenerba')-2,1) as sonuc;
sonuc
R
-- Temel Tarih İşlemleri (DateTime Fonksiyonları)
Select GETDATE() as ŞUAN
ŞUAN
2011-12-30 16:05:34.457
Select YEAR(GETDATE()) as [Bu Yıl]
Bu Yıl
2011
Select MONTH(getdate()) as [Bu Ay]
Bu Ay
12
select Day('11.16.2010') as Gun;
Gun
16
select DAY(getdate()) as BuGün;
BuGün
30
select CONVERT(varchar,Getdate(),104);
30.12.2011
select CONVERT(varchar,DATEADD(day,12, getdate()),106);
11 Jan 2012
select DATEADD(year,14,getdate());
2025-12-30 16:09:48.577
select DATEADD(QUARTER,6,getdate());
2013-06-30 16:10:54.600
select DATEADD(WEEK,52,'11.20.2011');
2012-11-18 00:00:00.000
select DATEDIFF(year,'08.28.1986',getdate()) as [Denizin Yaşı];
Denizin Yaşı
25
select DATEDIFF(Day,'05.30.1989',getdate()) as [Deniz .. Gündür
Hayatta];
Deniz .. Gündür Hayatta
8249
select DATEDIFF(QUARTER,'08.28.1986',getdate()) as ' '; //2015-12-30
117
select CONVERT(varchar,DATEDIFF(HOUR,'06.06.1989',getdate()))+' sa' as
[Gamze Yaşı]; //2015-12-30
Gamze Yaşı
232888 sa
-- Bir gün kaç saniye ?
select CONVERT(varchar,DATEDIFF(second,'10.10.2010','10.11.2010')) + '
sn' as [Bir Gün];
Bir Gün
86400 sn
select DATEPART(year,getdate());
2015
select DATEPART(MONTH,'10.10.2010');
10
select DATEPART(N,Getdate());
16
-- Matematiksel ifadeler (Math Fonksiyonları)
select Floor(RAND()*9+1);
8
select SQRT(144);
12
select SQUARE(9);
81
select POWER(2,64);
Msg 232, Level 16, State 3, Line 1
Arithmetic overflow error for type int, value = 18446744073709552000.000000.
DML Data Manipulation Language

DML Data Manipulation Language

  • 1.
    DML Data ManipulationLanguage Kategori SQL -------------------------- DML (Data Manipulation Language)------------------------ -- Select -- Insert -- Update -- Delete Sql’e dair bazı select sorgulamalarına başlayalım. Bir takım fonksiyonları da kullanacağız. İlerleyen zamanlarda fonksiyonlara yönelik detaylı çalışmalarımız tekrardan olacak. Şimdi SQL Server Management Studio’yu açın ve Sql’lerin keyfini çıkartın. için İyi Eğlenceler. -- ******* SELECT ***** select 44 44 select 4+5 9 select 44, 4+5 44 | 9 select 5 * 10 as Sonuc Sonuc
  • 2.
    50 select 4*5 asCARPIM, 4+5 as TOPLAM select 'Hizlan' as ISIM ISIM Hizlan select 'Hizlan' as ISIM, 'ERPAK' as SOYAD, '1979' as [7+9] (SQL SERVER) ISIM SOYAD 7+9 Hizlan ERPAK 1979 -- Temel Metinsel işlemler (String Fonksiyonlar) select UPPER('Yazilimcoplugu') as İsim; YAZİLİMCOPLUGU select UPPER('hizlan') as isim, UPPER('erpak') as Soyad; İsim Soyad HİZLAN ERPAK select lower('HiZlAn') as [lower('İsim')] -- MSSQL buyuk ve kucuk harf duyarlı değildir. select SUBSTRING('Yazilim Coplugu',3,2) as sonuc; sonuc zi CARPIM TOPLAM 20 9
  • 3.
    select LEN('Yazilim Coplugu')as sonuc; sonuc 15 select LEN('Yazilimcoplugu') as sonuc; sonuc 14 select SUBSTRING('Yazilimcoplugu',2,LEN('Yazilimcoplugu')-2) as sonuc; sonuc azilimcoplug select ' Yazilim Coplugu ' as sonuc; sonuc Yazilim Coplugu select LTRIM(' Yazilim Coplugu') as sonuc; sonuc Yazilim Coplugu select RTRIM(' Yazilim Coplugu ') as sonuc; sonuc Yazilim Coplugu select LTRIM(RTRIM(' Yazilim Coplugu ')) as sonuc; sonuc Yazilim Coplugu Select REPLACE('Yazilim Coplugu',' ','Sistem') as sonuc sonuc
  • 4.
    YazilimSistemCoplugu Select LEFT('Yazilim Coplugu',3)as sonuc; sonuc Yaz select RIGHT('Yazilim Coplugu',4) as sonuc; sonuc lugu select Left(Right(LOWER(REVERSE(UPPER(LTRIM(SUBSTRING('Yazilimcoplugu',5 ,LEN('Yazilimcoplugu')-5))))),1),2)+'Database' as İsim; İsim lDatabase -- Ne kelimesi olursa olsun sondan 3. harf gelsin select Substring(Upper('Fenerbahçe'),Len('Fenerba')-2,1) as sonuc; sonuc R -- Temel Tarih İşlemleri (DateTime Fonksiyonları) Select GETDATE() as ŞUAN ŞUAN 2011-12-30 16:05:34.457
  • 5.
    Select YEAR(GETDATE()) as[Bu Yıl] Bu Yıl 2011 Select MONTH(getdate()) as [Bu Ay] Bu Ay 12 select Day('11.16.2010') as Gun; Gun 16 select DAY(getdate()) as BuGün; BuGün 30 select CONVERT(varchar,Getdate(),104); 30.12.2011 select CONVERT(varchar,DATEADD(day,12, getdate()),106); 11 Jan 2012 select DATEADD(year,14,getdate()); 2025-12-30 16:09:48.577 select DATEADD(QUARTER,6,getdate()); 2013-06-30 16:10:54.600
  • 6.
    select DATEADD(WEEK,52,'11.20.2011'); 2012-11-18 00:00:00.000 selectDATEDIFF(year,'08.28.1986',getdate()) as [Denizin Yaşı]; Denizin Yaşı 25 select DATEDIFF(Day,'05.30.1989',getdate()) as [Deniz .. Gündür Hayatta]; Deniz .. Gündür Hayatta 8249 select DATEDIFF(QUARTER,'08.28.1986',getdate()) as ' '; //2015-12-30 117 select CONVERT(varchar,DATEDIFF(HOUR,'06.06.1989',getdate()))+' sa' as [Gamze Yaşı]; //2015-12-30 Gamze Yaşı 232888 sa -- Bir gün kaç saniye ? select CONVERT(varchar,DATEDIFF(second,'10.10.2010','10.11.2010')) + ' sn' as [Bir Gün]; Bir Gün 86400 sn
  • 7.
    select DATEPART(year,getdate()); 2015 select DATEPART(MONTH,'10.10.2010'); 10 selectDATEPART(N,Getdate()); 16 -- Matematiksel ifadeler (Math Fonksiyonları) select Floor(RAND()*9+1); 8 select SQRT(144); 12 select SQUARE(9); 81 select POWER(2,64); Msg 232, Level 16, State 3, Line 1 Arithmetic overflow error for type int, value = 18446744073709552000.000000.