TABLO OLUŞTURMA
Create database veritabaniismi;
Use veritabaniismi;
Create table ogrenci (no int,adı varchar(20),soyad varchar(20));
TABLOYA VERİ EKLEME
İnsert into orgenci values(20,Serkan,kaya);
Select*from ogrenci;
GÜNCELLE
Update ogrenci set ad=Serkan where ogrenci_no=20;
SİL
Delete from ogrenci where ogrenci_no=20 ;
KAÇ KAYIT OLDUĞU
Select count(*) ogrenci;
SADECE SECTİGİNİ GÖSTEREN( AD,SOYAD vb)
Select distinct(ad) from ogrenci;
Select distinct ad from ogrenci;
YENİ ALAN EKLEME
Alter table ogrenci add adres varchar(10);
Alter table ogrenci add column adres varchar(10);
TOPLAMI ORTALAMASI ENBÜYÜK VE ENKÜÇÜNÜGÜNÜ BULUNUZ
Select sum(ogrenci_no) ogrenci; toplama
Select avg(ogrenci_no) ogrenci; ortalama
Select max(ogrenci_no) ogrenci; enbüyük
Select min(ogrenci_no) ogrenci; en küçük
KÜÇÜKTEN BÜYÜĞE VE BÜYÜKTEN KÜÇÜĞE SIRALA
Select *from ogrenci order by ogrenci_no asc;
Select*from ogrenci order by ogrenci_no desc;
A HARFİ İLE BASLAYANLAR
Select *from ogrenci where ad like a%;
ŞARTA GÖRE SIRALAMALAR
Select max (kredi), ad from ogrenci group by ad;
ŞART BELİRTİLİ İSE
Select*from ogrenci where kredi between 300 and 800;
Select ad from ogrenci where kredi>500 and kredi<900;
TABLODA ALAN SİLME
delete from tabloismi adı where no;
TABLOYU SİLME
delete from tabloismi;
VERİ TABANINI SİLMEK
drop from veritabanıadı;
ALANA TÜM KAYITLARI GÖSTEREN KOD
Select distinct bulum from kitap;
TÜRLERİ VE KAREKTER UZUNLUGUNU DEGİŞTİREN KOD
alter table ogrenciler modify column ogrenci _ad varchar(30);
TABLOYA YENİ ALAN SİLME
alter table ogrenciler drop column telefon;
SINIFLARI AYRI AYRI ORTALAMASINI GETİREN KOD
select sinif, avg(vize) from notlar group by sinif;
MYSQL DE VERİ TABALANLARINI VE TÜM TABLOLARIN İSİMLERİNİ GÖSTEREN KOD
Show databases; show tables;
TABLODA ALANLARI GÖSTEREN KOD
Describe tabloadi
Create database veritabaniismi;
Use veritabaniismi;
Create table ogrenci (no int,adı varchar(20),soyad varchar(20));
TABLOYA VERİ EKLEME
İnsert into orgenci values(20,Serkan,kaya);
Select*from ogrenci;
GÜNCELLE
Update ogrenci set ad=Serkan where ogrenci_no=20;
SİL
Delete from ogrenci where ogrenci_no=20 ;
KAÇ KAYIT OLDUĞU
Select count(*) ogrenci;
SADECE SECTİGİNİ GÖSTEREN( AD,SOYAD vb)
Select distinct(ad) from ogrenci;
Select distinct ad from ogrenci;
YENİ ALAN EKLEME
Alter table ogrenci add adres varchar(10);
Alter table ogrenci add column adres varchar(10);
TOPLAMI ORTALAMASI ENBÜYÜK VE ENKÜÇÜNÜGÜNÜ BULUNUZ
Select sum(ogrenci_no) ogrenci; toplama
Select avg(ogrenci_no) ogrenci; ortalama
Select max(ogrenci_no) ogrenci; enbüyük
Select min(ogrenci_no) ogrenci; en küçük
KÜÇÜKTEN BÜYÜĞE VE BÜYÜKTEN KÜÇÜĞE SIRALA
Select *from ogrenci order by ogrenci_no asc;
Select*from ogrenci order by ogrenci_no desc;
A HARFİ İLE BASLAYANLAR
Select *from ogrenci where ad like a%;
ŞARTA GÖRE SIRALAMALAR
Select max (kredi), ad from ogrenci group by ad;
ŞART BELİRTİLİ İSE
Select*from ogrenci where kredi between 300 and 800;
Select ad from ogrenci where kredi>500 and kredi<900;
TABLODA ALAN SİLME
delete from tabloismi adı where no;
TABLOYU SİLME
delete from tabloismi;
VERİ TABANINI SİLMEK
drop from veritabanıadı;
ALANA TÜM KAYITLARI GÖSTEREN KOD
Select distinct bulum from kitap;
TÜRLERİ VE KAREKTER UZUNLUGUNU DEGİŞTİREN KOD
alter table ogrenciler modify column ogrenci _ad varchar(30);
TABLOYA YENİ ALAN SİLME
alter table ogrenciler drop column telefon;
SINIFLARI AYRI AYRI ORTALAMASINI GETİREN KOD
select sinif, avg(vize) from notlar group by sinif;
MYSQL DE VERİ TABALANLARINI VE TÜM TABLOLARIN İSİMLERİNİ GÖSTEREN KOD
Show databases; show tables;
TABLODA ALANLARI GÖSTEREN KOD
Describe tabloadi