Oracle SQL in 10 Minutes - Asim Abbasi

CH1: SQL Basics | CH2:  SQL Operators | CH3:  SQL Built-in Functions | CH4: SQL Joins | CH5: UPDATE, INSERT & DELETE Statements | CH6: CREATE, ALTER & DROP Statements | CH7: Constraints | CH8: Linking Tables vs Joining Tables | CH9: SQL Statements for Other Database Objects | CH10: SQL Statements for Database Security

Chapter 1: SQL Basics

Page #: 1 | 2 | 3 | 4

 

Anyone knowing English language can easily imagine what the output of this statement would look like. The output will be three fields with all the records from address_book table. So you completed your first SQL statement.

Figure 3: The SELECT Statement is used to query or retrieve information.
________________________________________

 

The SELECT statement as the name says is used to extract data from Oracle Database. The syntax for the simplest SELECT statement is as follows.

SELECT column_name1, column_name2, …
FROM table_name1;

Example:

SELECT *
FROM emp;

This command will display all the fields of the table emp and all of the records.

Example:

SELECT ename, sal
FROM emp
WHERE sal > 2000;

The result of this statement will be only two columns of emp table and only those records where salary is greater than 2000.

Example:

SELECT ename, salary
FROM emp
WHERE sal > 2000
ORDER BY ename;

The output of this statement will be exactly the same as the one above except that the output will be sorted based on ename column.

Chapter 1: Overview

Page #: 1 | 2 | 3 | 4

CH1: SQL Basics | CH2:  SQL Operators | CH3:  SQL Built-in Functions | CH4: SQL Joins | CH5: UPDATE, INSERT & DELETE Statements | CH6: CREATE, ALTER & DROP Statements | CH7: Constraints | CH8: Linking Tables vs Joining Tables | CH9: SQL Statements for Other Database Objects | CH10: SQL Statements for Database Security

Share with others: