0% found this document useful (0 votes)
2 views

SQL Queries

The document provides an overview of SQL queries in Open Office Base, detailing the definition of queries, methods to create them, and the SQL command structure. It includes examples of various SQL commands such as SELECT, INSERT, UPDATE, and DELETE, along with their usage in different scenarios. Additionally, it explains the purpose of clauses like WHERE and ORDER BY, and differentiates between DDL and DML commands.

Uploaded by

Goethe Institut
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Queries

The document provides an overview of SQL queries in Open Office Base, detailing the definition of queries, methods to create them, and the SQL command structure. It includes examples of various SQL commands such as SELECT, INSERT, UPDATE, and DELETE, along with their usage in different scenarios. Additionally, it explains the purpose of clauses like WHERE and ORDER BY, and differentiates between DDL and DML commands.

Uploaded by

Goethe Institut
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL QUERIES

1. What do you mean by query in open office base?


A query is a request to collect specific information from a table or combination of tables.

2. In how many ways you can create query in open office base?
3 ways
a. Create query in Design view
b. Create query using wizard
c. Create query in SQL view
3. Name the query language which is used in base?
SQL
4. Which command is used to retrieve data from the table?
Select command is used to retrieve data from the table.
5. Name the categories of SQL commands.
DDL,DML,DCL,TCL.
6. Differentiate between DDL and DML commands
DDL:
1. It stands for Data Definition Language
2. Ex: Create, Alter, Drop

DML:

1. It stands for Data Manipulation Language


2. Ex: Insert, Update, Delete

7. Identify the DML Commands from the following:


Create, alter, Insert, Delete
8. ____ is the most commonly used Data Manipulation Language Command.
Select
9. Name two clauses which can be used with select command
Where
Order by
10. Write the select command to display all the records of table “ book”

Select*from book;

11. Write the shortcut to execute query in “ create query in SQL view” of base.

F5

12. What is the purpose of where clause in select command?


Where clause is used to retrieve specific record from the table.
13. What is the purpose of order by clause in select command?
Order by clause is used to arrange the records in ascending order or descending order.
14. Write the queries for the following table : EMP
EMP_ID ENAME SALARY
1 Suman 20000
2 Sujay 32000
3 Ragav 30000
SQL Commands
1. Display the salary of all the employees after incrementing by Rs.1000.
Select SALARY+1000 from emp;
2. Display the employee id and salary of all the employees after decreasing by Rs 500.
Select EMP_ID,SALARY-500 from Emp;
3. Display the name and salary of all the employees after incrementing it as thrice the
amount of present salary.
Select ENAME,SALARY*3 from EMP;
4. Display the employee id , name and salary of all the employees after decrementing it as
half the amount of present salary.
Select EMP_ID,ENAME,SALARY/2 from EMP;
5. Display the employee id and name of all the employees.
Select EMP_ID, ENAME from EMP;
15. Write the queries for the following table : Student

ADMNO NAME CLASS HOUSE


1001 Sonam 9 Blue
1002 Ravi 10 Yellow
1003 Poonam 10 Green

1. Display the entire table


Select * from student;
2. Display the list of students whose house color is blue.
Select*from student where HOUSE=”Blue”;
3. Display the admission number of students whose house color is green.
Select ADMNO from Student where HOUSE=”Green”;
4. To view records in ascending order of admission number.
Select*from student order by ADMNO;
5. Display the records of class 10 student.
Select * from students where class=10;
6. Display the class of ‘Ravi’
Select class from student where NAME = ‘Ravi’;
7. Insert into Student values( 1004,” Aman” ,11,” Blue” ) ;
16. Which command is used for the following task in database?
1. To insert a new record – Insert
2. To modify the existing data – Update
3. To delete a record – Delete
4. To display record – Select
17. Write the queries for the following table : ITEM
ITEMNO INAME PRICE QTY
12 Pen 10 17
13 Eraser 5 15
14 Notebook 15 20

1. Write a query to insert a new record of following details


15,”pencil”,20,10

Insert into ITEM values(15,”Pencil”,20,10)


2. Write a query to display detail of ITEM whose quantity is more than 10.
Select * from ITEM where QTY>10;
3. Write a query to change the quantity of ITEM number 13 to 25
Update ITEM set QTY =25 where ITEMNO =13;
4. Display the total amount of each item. The amount must be calculated as the price
multiplied by quantity for each item.
Select price* QTY from ITEM;
5. Display the name of ITEM whose price is 10
Select INAME from ITEM where price =10;
6. Display all the records in descending order of price.
Select*from ITEM order by PRICE desc;
7. Identify the primary key from table ITEM.
ITEMNO
8. Write the suitable data type of field “INAME”
Char or Varchar
9. Write a query to increase the price of all items by Rs 2.
Update ITEM set PRICE =PRICE +2;
10. Write a query to decrease the price of all ITEM by Rs 2 whose price is less than 20.
Update ITEM set PRICE = PRICE -2 where PRICE<20;
18. By default , data is arranged in ____ order using ORDER BY clause.
Ascending Order.
19. Which clause is used for the following :
1. To display specific record. – where clause
2. To display records in a particular order. – order by clause
20. Consider the following table “SCHOOL” and write the queries for the following :
ROLLNO STUDENTNAME DOB CLASS
R12 Aman 11-03-2012 10
R43 Sumit 15-03-2015 9
R23 Dhriti 18-03-2010 10
R1 Parth 21-03-2010 9

1. Write a query to display all records in alphabetical order of name .


2. Write a query to change the class of “ dhriti” from 10 to 7.
3. Write a query to display the above table.
4. Write a query to display Roll number and Name of class 10 students
5. Display detail of all students of class 9
6. Insert a new record with value :’R24’,’Kamal’,’15-05-2010’,8
7. Display detail of all students whose class is greater than 9.

Answers:
1. Select *from SCHOOL order by STUDENTNAME;
2. Update SCHOOL set CLASS =7 where STUDNETNAME =’Dhriti’
3. Select * from SCHOOL;
4. Select ROLLNO,STUDNETNAME from SCHOOL where CLASS =10;
5. Select * from SCHOOL where CLASS = 9;
6. Insert into SCHOOL values(‘R24’,’Kamal’,’15-05-2010’,8);
7. Select *from SCHOOL where CLASS>9;

You might also like