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

Oracle SQL and SAS Workshop

This document provides an overview of an Oracle SQL and SAS workshop that includes 10 practice sessions on various SQL and SAS topics: 1. The workshop covers step-by-step processes, practices, questions and discussions for both beginning and advanced SQL and SAS programmers. 2. The practice sessions cover naming conventions, selecting data, using indexes, parallel queries, joins, large table creation, and connecting SAS to Oracle databases for SQL pass-through. 3. Committing transactions to make changes permanent is emphasized, as well as commenting code for readability.

Uploaded by

Jialuo Cheng
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Oracle SQL and SAS Workshop

This document provides an overview of an Oracle SQL and SAS workshop that includes 10 practice sessions on various SQL and SAS topics: 1. The workshop covers step-by-step processes, practices, questions and discussions for both beginning and advanced SQL and SAS programmers. 2. The practice sessions cover naming conventions, selecting data, using indexes, parallel queries, joins, large table creation, and connecting SAS to Oracle databases for SQL pass-through. 3. Committing transactions to make changes permanent is emphasized, as well as commenting code for readability.

Uploaded by

Jialuo Cheng
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Oracle SQL and SAS Workshop

Session 1
Step by Step Process

Practice and Enjoy!

Questions and Discussions

Advanced SAS Programmer

Optimizing Oracle SQL


PRACTICES !!!

Practice # 1
Be Bold!
Learn from Mistakes!
Naming Conventions
for Coding Script

Practice # 2
HIMYM
Death Star HTGAWM
TGIF

Manhattan Project
GOT

Before Coding,
think of “Cool”
Script Names

 Name of Module: MED, HCP, OPF


 Purpose of Script: Product_Review, Contribution_Review
 Name of Client/Vendor: United, Cigna, ColoradoWC
 Date: 05-31-2019
Angry Bird @angrybird
Worked 2 hours to craft my masterpiece and “GONE” in second with
System Reboot!!! #angermanagement #saveyourscript

Constantly
Click “SAVE”
Comments and
Documentations

Practice # 3
NoobMaster69
@noobmaster69

Ideal code includes characteristics such as a good level of readability. Readability of code
involves the level of ability to read and clearly understand code that has been written. As with
the concept of an author including descriptions of event, places, and characters for a story in
order for readers to understand the story; an author of code should also include descriptions of
what lines of code should do and other explanations for code in order to assist readers.
#comment #ctrl+slash #uncomment #ctrl+shift+slash
––
/*
*/
Power of
SELECT * FROM

Practice # 4
Select Star
@selectstar

Before you do any advanced queries, it is important to know what’s in the table(s) you are
going to query. #select*from #knowyourtables #knowyourcolumns
Use SQL Indexes

Practice # 5
Librarians
@Librarians

Why Index? Database tables can get big. Stupendously, colossally big. Scanning through
millions, billions or trillions of rows to return just two or three is a huge waste. Waste and index
can help you avoid. #index

What is Index? An index stores the values in the indexed column(s). And for each value the
locations of the rows that have it. Just like the index at the back of a book. This enables you to
hone in on just the data that you're interested in.

• WHERE MODULE_ID = ‘MED’

• WHERE CHARGE >= 1000000

• WHERE ROWNUM <= 50

• WHERE SUBSTR(PROC,5,1) = ‘T’


Librarians
@Librarians

How to find index columns in the Table?


#findingmeme #findingindexcolumns #ALL_IND_COLUMNS
Use Parallel
Statement

Practice # 6
Lego Batman
@legobatman

HELP! Superheroes in JLA, I need to assemble my Batmobile, but all components are
scattered all over @middlezealand @oldwest @cloudcuckooland
Can I borrow your storage to speed up my assembly? BTW, @legosuperman I need to borrow
your WIFI. NEVER MIND! Just hacked in~
@legosuperman #notrealsuperman @legowonderwoman @legogreenlatern @aquaman

Justice League of America


@JLA

SURE THING!
Lego Batman
@legobatman

AWESOME! /*+ PARALLEL(A,8) FULL (A)*/ #batmobile


Join Tables using
Subqueries

Practice # 7
Inside Out
@insideout
Best practice of join multiple tables is starting subqueries with Indexes for each join; (Middle)
Then select columns you need from each subqueries; (Move to Top)
Finally, establish the relationships between those subqueries. (Move to Bottom)
#middletotoptobottom
Use ROWNUM < 1 and
INSERT /*+APPEND*/ for
creating large tables
Practice # 8
Monstrosity Godzilla
@Monstrosity Godzilla
It is recommended to create large “monstrosity” table using Parallel Statement and
INSERT /*APPEND*/ to improve the performances

• Data is appended to the end of the table, rather than attempting to use existing free space
within the table.
• Data is written directly to the data files, by-passing the buffer cache.
• Referential integrity constraints are not considered.
• No trigger processing is performed.

#wrecking #rownum<1 #insertappend


Monstrosity Godzilla
@Monstrosity Godzilla
Moving forward…
COMMIT!

Practice # 9
100%Commitment
@100%Commitment
In Oracle, although you can successfully create a record with an INSERT statement like the
one from @Monstrosity Godzilla, the record isn’t made permanent to other users of your
system until you save it. A DML statement such as an INSERT statement is always executed in
conjunction with either a COMMIT statement, which saves the change.

• INSERT STATEMENT…; COMMIT;

• DELETE STATEMENT…; COMMIT;

• UPDATE STATEMENT…; COMMIT;

• CREATE TABLE or CREATE VIEW AS …; COMMIT;


SAS:
Oracle SQL
Pass-through
Practice # 10
SAS
@SAS
The SQL pass-through facility uses SAS/ACCESS to connect to a DBMS and to send statements directly to the DBMS
for execution. An alternative to the SAS/ACCESS LIBNAME statement, this facility lets you use the SQL syntax of your
DBMS. It supports any SQL that is not ANSI-standard that your DBMS supports.

COMMIT!
• The Oracle interface can connect to multiple databases (both local and remote) and to multiple user IDs. If you use
multiple simultaneous connections, you must use an alias argument to identify each connection. If you do not specify
an alias, the default alias, oracle , is used.

• Here are the database-connection-arguments for the CONNECT statement.

• USER=<'>Oracle-user-name<'>


Practice # 9
specifies an optional Oracle user name. If you specify USER=, you must also specify PASSWORD=.

PASSWORD= <'>Oracle-password<'>
specifies an optional Oracle password that is associated with the Oracle user name. If you omit an Oracle password,
the default Oracle user ID OPS$sysid is used, if it is enabled. If you specify PASSWORD=, you must also specify
USER=.

• PATH=<'>Oracle-database-specification<'>
specifies the Oracle driver, node, and database. Aliases are required if you are using SQL*Net Version 2.0 or later. In
some operating environments, you can enter the information that is required by the PATH= statement before invoking
SAS.
SAS
@SAS
Oracle SQL, I am coming…@oraclesql

COMMIT!

Practice # 9
Questions?

Proprietary and Confidential 28

You might also like