##Create database - inlocuiti cu numele potrivit in cazul fiecarui student CREATE DATABASE IF NOT EXISTS d; use d; #Creati tabela tStudent; in aceasta tabela veti importa dintr-un fisier datele studentilor create table tStudent (i int primary key, cNume varchar(20), cInitiala varchar(10), cPrenume varchar(30), cGrupa varchar(10));
Pentru a importa datele studentilor, descarcati fisierul 131IE.csv in directorul curent; in comanada de mai jos, inlocuiti calea catre fisier cu cea in care l-ati salvat:
LOAD DATA LOCAL INFILE 'C:/131IE.csv' INTO TABLE tStudent FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
#Vizualizati continutul tabelei SELECT * from tStudent; #Selectati studentii care au nume care incep cu B SELECT * FROM tStudent WHERE cNume LIKE 'B%'; #Selectati studentii care au nume care se termina cu a SELECT * FROM tStudent WHERE cNume LIKE '%a'; #Selectati studentii care au nume care contin un t SELECT * FROM tStudent WHERE cNume LIKE '%t%'; #Selectati studentii care au nume care au exact 5 caractere SELECT * FROM tStudent WHERE cNume LIKE '_____'; #Utilizand regexp #Selectati studentii ai caror nume incepe cu C SELECT * FROM tStudent WHERE cNume REGEXP '^C'; #Selectati studentii ai caror nume incepe cu B (majuscula) SELECT * FROM tStudent WHERE cNume REGEXP BINARY '^B'; #Selectati studentii ai caror nume incepe cu b (minuscula) SELECT * FROM tStudent WHERE cNume REGEXP BINARY '^b'; #Selectati studentii care au nume care se termina cu e SELECT * FROM tStudent WHERE cNume REGEXP'e$'; #Selectati studentii care au nume care au exact 5 caractere SELECT * FROM tStudent WHERE cNume REGEXP '^.....$'; SELECT * FROM tStudent WHERE cNume REGEXP '^.{5}$';