select
a query that is used to retrieve data or display data. The data have been taken
or may be displayed in the application that we created or used to control the
program.
In this tutorial we will discuss the basics of the SELECT statement in
Oracle. To use the SELECT statement is advanced, we will discuss in the next tutorial.
Below is the basic syntax of the SELECT statement in Oracle:
Keyword * is used to display all the data in a table.
ALL keyword is used to display all the data in a table.
* Functions the
same as the keyword.
DISTINCT keywords are used to display the data, where the same data or
duplicates will be eliminated.
WHERE clause is used to display data based on specific criteria or
conditions.
In the WHERE clause, we can use the function LIKE, BETWEEN, IS
NULL, IS NOT NULL, EXISTS, NOT EXISTS, and so on. WHERE clause is optional
alias shall not be included in the SELECT statement.
GROUP BY clause is used to classify data according to the criteria. GROUP
BY clause is usually used in the use Aggregate Functions in SQL. GROUP BY
clause is optional alias is not mandatory.
HAVING clause should be used when you use the GROUP BY clause. If you use
a HAVING clause without a GROUP BY clause, then the query will display an error
message. HAVING clause is optional alias is not mandatory.
ORDER BY clause is used to sort the data in ascending or descending
order. If you do not include the keyword ASC or DESC to the ORDER BY clause,
then the default is the data sorted in ascending. ORDER BY clause is optional
alias is not mandatory.
Exercises
Exercise # 1
Create a table named EMPLOYEE with a column structure as follows:
NIK VARCHAR2 (5)
name VARCHAR2 (30)
gender CHAR (1)
position VARCHAR2 (30)
Exercise # 2
Enter the data in the EMPLOYEES table above with the following data:
NIK Name Gender Position
001 Naura Krasiva P Director
Bayu 002 Indardi L Staff
Nurul Hikmah P 003 Managers
004 Bradpit L Staff
005 L Chief Alexis Sanches
Exercise # 3
Show all the data in the table EMPLOYEES
Answer :
Exercise # 4
Show the data NIK, Name in the EMPLOYEES table
Answer # 4
Exercise # 5
Show all data on the EMPLOYEES table-sex male
Answer # 5
References
:
http://naura-lab.blogspot.co.id/2015/01/bagaimana-cara-menggunakan-select.html
Sistem Basis Data,Utami Ema | Anggit Dwi Hartanto, 2012, Yoyakarta, Andi.
Sistem Basis Data,Utami Ema | Anggit Dwi Hartanto, 2012, Yoyakarta, Andi.



No comments:
Post a Comment