· 6 years ago · Apr 08, 2019, 09:52 AM
11. create database sprawdzian;
22. use sprawdzian;
3 create table sprawdzian.Dane1(x int,y char(1));
43. show tables from sprawdzian;
54. select user from mysql.user where host='localhost';
65. create user adam identified by 'hasło1';
76. set password for adam=password('hasło2');
87. rename user adam to adam @localhost;
98. create user adam@149.156.202.152 identified by "haslo3";
109 show grants for adam@localhost;
1110. grant select on mysql.user to adam@localhost;
1211. grant all on sprawdzian.Dane1 to adam@localhost;
1312. revoke all privilliges on sprawdzian.Dane1 to adam@localhost;
1413. rename user adam@localhost to ewa@localhost;
1514. drop user adam@149.156.202.152, ewa@localhost;
1615. select user();
1716. insert into sprawdzian.Dane1 values (1,'1'),(2,NULL),(NULL,'3'),(NULL,NULL);
1817. create table sprawdzian.Dane2 like sprawdzian.Dane1;
1918. rename table sprawdzian.Dane2 to sprawdzian.Dane3;
2019. create table sprawdzian.Dane2 select*from Dane1;
2120. delete*from Dane1;
2221. truncate table Dane2;
2322. drop table sprawdzian.Dane1,sprawdzian.Dane2,sprawdzian.Dane3;
2423. create table sprawdzian.Wykładowcy(Idw int unsigned,Nazwisko char(25),Wiek int unsigned);
2524. alter table sprawdzian.Wykładowcy add Imię char(15) after Idw, modify Nazwisko char(30), drop Wiek;
2625. alter table sprawdzian.Wykładowcy add primary key(Idw),modify Idw int unsigned auto_increment, add constraint St_u unique(Imię,Nazwisko);
2726. show index from sprawdzian.Wykładowcy;
2827. alter table sprawdzian.Wykładowcy drop key St_u;
2928. create table sprawdzian.Przedmioty(Idp int unsigned,Nazwa char(30),Idw int unsigned);
3029. alter table sprawdzian.Przedmioty add primary key (Idp), modify Idp int unsigned auto_increment, modify Nazwa char(30) not null, add foreign key (Idw) references sprawdzian.Wykładowcy (Idw);
3130. drop database if exists sprawdzian;
3231. source C:/Users/student/downloads/world8.txt;
3332. use world;
3433. select continent, name, population from country where IndepYear is null order by continent, population;
3534. select continent, avg(population/surfaceArea) from country group by continent;
3635. select continent, count(name) from country where name like '%Island%' group by continent;
3736. select concat(country.name,'-',city.name) as 'Kraj-Stolica' from city, country where country.capital=city.ID;
3837. select name as Kraj, population as Populacja, continent as Kontynent from country where continent in ('Europe','Asia','North America') order by name, population;
3938. select city.name as Miasto, country.name as Kraj, city.population as Ludność from city join country on city.countrycode=country.code where city.population>5000000 group by country.name order by city.population;
4039. select continent as Kontynent, (population/1000000) as Åšrednia_populacja_kraju from country where population>5000000 order by (population/1000000);