Jon Heller
Clive, IA, USA
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484245163 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-4516-3 e-ISBN 978-1-4842-4517-0
https://doi.org/10.1007/978-1-4842-4517-0
Jon Heller 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Introduction
This book will set you on the path to becoming an Oracle SQL expert. It will inspire you to achieve more with your database queries.
This book is not a copy of the SQL Language Reference , will not quiz you about syntax trivia, and will not prepare you for an exam. But it will challenge the way you think about writing Oracle SQL. And I hope you have fun reading it.
Why Learn More About Oracle SQL?
Any database can store data, but Oracle is designed to help us process data. Many applications treat the database as a glorified text file, and there are many opportunities to use the database engine to improve our programs.
Oracle SQL is a great programming language and has many advantages compared to other languages and SQL implementations.
Declarative: Declarative languages let us tell the computer what we want, without having to specify how to do it. Declarative languages are different than traditional imperative languages and can be difficult at first. (Whenever we find ourselves wanting to use a loop in SQL, thats a clue were thinking in the wrong programming paradigm.) Declarative languages let the compiler handle the details, leading to simpler and faster code. But if we need to control exactly how our code runs, we still have imperative options, such as PL/SQL, hints, and the MODEL clause.
Popular: Oracle is one of the most popular databases in the world. And SQL is one of the most popular programming languages in the world.
Portable: SQL and PL/SQL are entirely platform independent. Other than a rare bug, we never need to worry about which operating system is running our SQL.
Clear and concise: The basic syntax is simple and readable, and the relational model is built on a few simple ideas. (If this description doesnt match your reality, Part III will explain how to make your code look better.)
Interpreted: Statements run immediately, without a separate compilation step. Integrated development environments can take advantage of interpreted languages and let us instantly run programs, debug our code, and get results.
Powerful: Oracle SQL has enough features to solve almost any problem. For those rare exceptions, PL/SQL can handle them and integrate perfectly with SQL.
Fast: Oracle SQL is powerful enough to let us bring algorithms to our data, instead of bringing data to our algorithms. Ignore those shallow benchmarks that compare running SELECT COUNT(*) FROM EMPLOYEE a thousand times. Real-world performance is more complicated than that and depends more on an optimizer than the speed of running trivial commands.
Despite all those advantages, Oracle SQL is scandalously under-used. There are huge opportunities to improve our systems by using SQL more often.
Target Audience
This book is for anyone who already knows Oracle SQL and is ready to take their skills to the next level. For those of you who are already skilled at Oracle SQL, this book will give you a different way to think about the language.
There are many groups of people who frequently use Oracle databases. Their reasons for using the database may differ, but they can all benefit from improving their SQL knowledge.
Database developers: If youre already frequently using an Oracle database, then you have the most to gain from this book. This book will help you with many phases of your software development life cycle. Even if you already know many of the advanced features, you will still benefit from the discussions about setting up the environment, SQL programming styles, and SQL performance tuning.
Application/front end/full stack developers: Many applications only use simple queries like SELECT * FROM EMPLOYEES or have a framework that automatically takes care of database access. This book wont try to convince you to put all your business logic inside the database. But it will help you find great opportunities to simplify your code and improve performance, by using new SQL programming styles and advanced features.
Data analysts and testers: Oracle SQL is the perfect language for analyzing, testing, and comparing data. Much of the advice in this book will help with those tasks.
Data scientists: You probably wont use Oracle SQL for data mining (although Oracle does have a data mining option). But if youre reading or writing to an Oracle database, Oracles advanced features can at least help you with much of the tedious processing and formatting.
Database administrators: SQL is the life blood of an Oracle database. If you administer Oracle, youll need to work with those SQL statements and help others improve them. And there are many times when an advanced SQL statement can help you perform administrative tasks better.