0% found this document useful (0 votes)
13 views25 pages

Les01 15+

The document provides an overview of SQL concepts such as using column aliases, concatenation operators, and literal character strings in SELECT statements. It also introduces the iSQL*Plus environment for executing SQL commands, displaying table structures, and managing script files. Additionally, it highlights the differences between SQL statements and iSQL*Plus commands.

Uploaded by

bazalsarfraz7863
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views25 pages

Les01 15+

The document provides an overview of SQL concepts such as using column aliases, concatenation operators, and literal character strings in SELECT statements. It also introduces the iSQL*Plus environment for executing SQL commands, displaying table structures, and managing script files. Additionally, it highlights the differences between SQL statements and iSQL*Plus commands.

Uploaded by

bazalsarfraz7863
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Using Column Aliases

SELECT last_name AS name, commission_pct comm


FROM employees;

SELECT last_name "Name" , salary*12 "Annual Salary"


FROM employees;

1-1 Copyright © 2004, Oracle. All rights reserved.


START

1-2 Copyright © 2004, Oracle. All rights reserved.


Concatenation Operator

A concatenation operator:
• Links columns or character strings to other
columns
• Is represented by two vertical bars (||)
• Creates a resultant column that is a character
expression
SELECT last_name||job_id AS "Employees"
FROM employees;

1-3 Copyright © 2004, Oracle. All rights reserved.


Literal Character Strings

• A literal is a character, a number, or a date that is


included in the SELECT statement.
• Date and character literal values must be enclosed
by single quotation marks.
• Each character string is output once for each
row returned.

1-4 Copyright © 2004, Oracle. All rights reserved.


Using Literal Character Strings

SELECT last_name ||' is a '||job_id


AS "Employee Details"
FROM employees;

1-5 Copyright © 2004, Oracle. All rights reserved.


Alternative Quote (q) Operator

• Specify your own quotation mark delimiter


• Choose any delimiter
• Increase readability and usability
SELECT department_name ||
q'[, it's assigned Manager Id: ]'
|| manager_id
AS "Department and Manager"
FROM departments;

1-6 Copyright © 2004, Oracle. All rights reserved.


Duplicate Rows

The default display of queries is all rows, including


duplicate rows.
SELECT department_id
FROM employees;
1


SELECT DISTINCT department_id
FROM employees;
2

1-7 Copyright © 2004, Oracle. All rights reserved.


Start m2

1-8 Copyright © 2004, Oracle. All rights reserved.


SQL and iSQL*Plus Interaction

SQL statements
Oracle
server
Internet
browser

iSQL*Plus Query results


commands

Formatted report
Client

1-9 Copyright © 2004, Oracle. All rights reserved.


SQL Statements Versus
iSQL*Plus Commands
SQL iSQL*Plus
• A language • An environment
• ANSI standard • Oracle-proprietary
• Keyword cannot be • Keywords can be
abbreviated abbreviated
• Statements manipulate • Commands do not allow
data and table definitions manipulation of values in
in the database the database
• Runs on a browser
• Centrally loaded; does not
have to be implemented
on each machine
SQL iSQL*Plus
statements commands

1-10 Copyright © 2004, Oracle. All rights reserved.


Overview of iSQL*Plus

After you log in to iSQL*Plus, you can:


• Describe table structures
• Enter, execute, and edit SQL statements
• Save or append SQL statements to files
• Execute or edit statements that are stored in
saved script files

1-11 Copyright © 2004, Oracle. All rights reserved.


Logging In to iSQL*Plus

From your browser environment:

1-12 Copyright © 2004, Oracle. All rights reserved.


iSQL*Plus Environment
8 9

1
6

2 3 4 5

1-13 Copyright © 2004, Oracle. All rights reserved.


Displaying Table Structure

Use the iSQL*Plus DESCRIBE command to display the


structure of a table:

DESC[RIBE] tablename

1-14 Copyright © 2004, Oracle. All rights reserved.


Displaying Table Structure

DESCRIBE employees

1-15 Copyright © 2004, Oracle. All rights reserved.


Interacting with Script Files

SELECT last_name, hire_date, salary


FROM employees;
1

1-16 Copyright © 2004, Oracle. All rights reserved.


Interacting with Script Files

1-17 Copyright © 2004, Oracle. All rights reserved.


Interacting with Script Files

1-18 Copyright © 2004, Oracle. All rights reserved.


Interacting with Script Files

D:\TEMP\emp_data.sql

2
3

1-19 Copyright © 2004, Oracle. All rights reserved.


iSQL*Plus History Page

1-20 Copyright © 2004, Oracle. All rights reserved.


iSQL*Plus History Page

1-21 Copyright © 2004, Oracle. All rights reserved.


Setting iSQL*Plus Preferences

2
3

1-22 Copyright © 2004, Oracle. All rights reserved.


Setting the Output Location Preference
2

1-23 Copyright © 2004, Oracle. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Write a SELECT statement that:
– Returns all rows and columns from a table
– Returns specified columns from a table
– Uses column aliases to display more descriptive
column headings
• Use the iSQL*Plus environment to write, save, and
execute SQL statements and iSQL*Plus
commands
SELECT *|{[DISTINCT] column|expression [alias],...}
FROM table;

1-24 Copyright © 2004, Oracle. All rights reserved.


Practice 1: Overview

This practice covers the following topics:


• Selecting all data from different tables
• Describing the structure of tables
• Performing arithmetic calculations and specifying
column names
• Using iSQL*Plus

1-25 Copyright © 2004, Oracle. All rights reserved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy