Você está na página 1de 3

1.

Select the code which shows the countries that end in A or L

SELECT name FROM world


WHERE name LIKE '%a' OR name LIKE '%l'

2. Select the code that shows the population density of China, Australia, Nigeria and France

SELECT name, population/area


FROM world
WHERE name IN ('China', 'Nigeria', 'France', 'Australia')

3. Show the name and population in millions for the countries of the continent 'South America'.

SELECT name, population


FROM world
WHERE continent LIKE 'South America'

4. Show the countries which have a name that includes the word 'United'

SELECT name
FROM world
WHERE name LIKE 'United %'

5. Exclusive OR (XOR). Show the countries that are big by area or big by population but not both. Show
name, population and area. A country is big if it has an area of more than 3 million sq km or it has a
population of more than 250 million.

SELECT name,population,area
FROM world
WHERE population >= 250000000
OR
area >= 3000000

6. Ako je već definirana tablica i treba dodati primarni ključ na stupac ID_ucenik, koji od ponuđenih upita je
ispravan

ALTER TABLE Ucenici


ADD PRIMARY KEY (ID_Ucenik);

7. Postavi upit koji dohvaća broj redaka u tablici Ucenici

SELECT COUNT(ime) FROM Ucenici

8. Postavi upit koji vraća najveću vrijednost u stupcu ocjena


SELECT MAX (ocjena) AS NajvecaOcjena FROM Ucenici

9. Postavi upit koji briše tablicu Ucenici

DROP TABLE Ucenici

10. Poredaj riječi tako da upit ispravno unose redak u tablicu Ucenici: 'Domagoj','Duvnjak'); INTO ,VALUES,
Ucenici, INSERT, (

INSERT INTO Ucenici Values(‘domagoj’,’duvnjak’)

11. Postavi upit koji briše učenika iz tablice Ucenici kome je prezime Karabatić

DELETE FROM Ucenici


WHERE prezime = ’Karabatić’

12. Ispravi sljedeći upit: CREATE Gradovi (id_grad int, naziv nchar, zupanija)

CREATE TABLE Gradovi


{
IdGrad int,
Naziv nchar,
Zupanija nchar,
}

13. What does SQL stand for?

Structured Query Language

14. Which SQL statement is used to extract data from adatabase?

SELECT

15. Which SQL statement is used to update data in adatabase?

UPDATE

16. Which SQL statement is used to insert new data in adatabase?

INSERT INTO
17. With SQL, how do you select a column named"FirstName" from a table named "Persons"?

SELECT FirstName FROM Persons

18. With SQL, how do you select all the records from atable named "Persons" where the value of the
column"FirstName" is "Peter"?

SELECT * FROM Persons WHERE FirstName='Peter'

19. With SQL, how do you select all the records from a table named "Persons" where the value of the column
"FirstName" starts with an "a"?

SELECT * FROM Persons WHERE FirstName LIKE 'a%'

20. With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and
the "LastName" is "Jackson"?

SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

21. With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?

INSERT INTO Persons (LastName) VALUES ('Olsen')

22. How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?

UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

23. With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?

DELETE FROM Persons WHERE FirstName = 'Peter'

Você também pode gostar