Oracle SQL and SAS Workshop
Oracle SQL and SAS Workshop
Session 1
Step by Step Process
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
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.
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
SURE THING!
Lego Batman
@legobatman
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.
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.
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.
• 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?