DBMS – LAB TEST NO : 1
1. Insert the missing statement to get all the columns from the Customers table.
* FROM Customers;
2. Write a statement that will select the City column from the Customers table.
Customers;
3. Select all records where the City column has the value "Berlin".
SELECT * FROM Customers
= ;
4. Select all records where the CustomerID column has the value 32.
SELECT * FROM Customers
CustomerID ;
5. Select all records where the City column has the value
'Berlin' and the PostalCode column has the value '12209'.
* FROM Customers
City = 'Berlin'
= '12209';
6. Select all records where the City column has the value 'Berlin' OR 'London'.
* FROM Customers
City = 'Berlin'
=' ';
7. Select all records from the Customers where the PostalCode column is empty.
SELECT * FROM Customers
WHERE ;
8. Select all records from the Customers where the PostalCode column is NOT empty.
SELECT * FROM Customers
WHERE ;
9. Update the City column of all records in the Customers table.
Customers
City = 'Oslo';
10. Set the value of the City columns to 'Oslo', but only the ones where
the Country column has the value "Norway".
Customers
City = 'Oslo'
Country = 'Norway';
11. update the City value and the Country value.
Customers
City = 'Oslo'
= 'Norway'
WHERE CustomerID = 32;
12. Delete all the records from the Customers table where the Country value is 'Norway'.
Customers
Country = 'Norway';
13. Delete all the records from the Customers table.
Customers;
14. Use the MIN function to select the record with the smallest value of the Price column.
SELECT
FROM Products;
15. Use an SQL function to select the record with the highest value of the Price column.
SELECT
FROM Products;
16. Select all records where the value of the City column starts with the letter "a".
SELECT * FROM Customers
17. Select all records where the value of the City column ends with the letter "a".
SELECT * FROM Customers
18. Select all records where the value of the City column contains the letter "a".
SELECT * FROM Customers
19. Select all records where the value of the City column does NOT start with the letter
"a".
SELECT * FROM Customers
20. Select all records where the second letter of the City is an "a".
SELECT * FROM Customers
WHERE City LIKE ' %';
21. Use the IN operator to select all the records where Country is either "Norway" or
"France".
SELECT * FROM Customers
'France' ;
22. Use the IN operator to select all the records where Country is NOT "Norway" and
NOT "France".
SELECT * FROM Customers
('Norway', 'France');
23. Use the BETWEEN operator to select all the records where the value of
the Price column is between 10 and 20.
SELECT * FROM Products
WHERE Price ;
24. Use the BETWEEN operator to select all the records where the value of
the ProductName column is alphabetically between 'Geitost' and 'Pavlova'.
SELECT * FROM Products
WHERE ProductName ;
25. When displaying the Customers table, make an ALIAS of the PostalCode column, the
column should be called Pno instead.
SELECT CustomerName,
Address,
PostalCode
FROM Customers;
26. When displaying the Customers table, refer to the table as Consumers instead
of Customers.
SELECT *
FROM Customers ;
27. What is the department name for DeptID E-102?
28. select all records from the Customers table, sort the result reversed alphabetically by
the column City. (use order by)
SELECT * FROM Customers
29. Select all records from the Customers table, sort the result alphabetically, first by
the column Country, then, by the column City. (use order by)
SELECT * FROM Customers
30.Write the correct SQL statement to create a new database called testDB.