Author: Randy Sims
Generate Random Values
One of the best builtin packages in Oracle for anyone who needs to create random data is DBMS_RANDOM. Not only can you use it to create random values, but you can also use it to make random selections. For instance, if you have a list of values that you want to assign randomly, you can weight […]
Continue Reading...Nested Tables as Collection Data Type and a Table Column
Sometimes, a table is designed with one column that can hold an array. An array in database design is a table. So, in Oracle, you can create a type as a table and then use this type as a column in another table. What we end up with is a nested table as a table column […]
Continue Reading...Oracle Recycle Bin: BIN$ and RB$$ files
Ever query all_source and come up with a strange object name that starts with BIN$ or RB$$? That is the recyclebin, holding on to tables and indexes you have deleted in the past until they are either released or aged out. If you are trying to make space by dropping objects, be sure to purge […]
Continue Reading...Oracle Single Row Numeric Functions
Exam Topic: Using Single-Row Functions to Customize Output – Describe various types of functions available in SQL Single row functions return a result for every row in a result. They can be used in any part of a SQL query, such as the SELECT lists or any part that can use a conditional statement. Oracle 11g has […]
Continue Reading...Change Oracle’s SQLPLUS EDitor
Not everyone wants to use sqlplus’ built in editor. It is a bit of a pain and not at all WYSIWYG. Thankfully, changing sqlplus to use another editor is an easy process where you change the _editor session variable to another value. For a more permanent change, you can alternatively change the setting in the […]
Continue Reading...Ampersand Substitution and Session Variables
Exam Topic: Restricting and Sorting Data – Use ampersand substitution to restrict and sort output at runtime The Ampersand (&) and Double-Ampersand (&&) are used in oracle as prompts for input. They are called “Substitution Variables.” They can be used to input a value or dynamically build or modify a statement at runtime. This allows you […]
Continue Reading...Sorting Data – the ORDER BY Clause
Exam Topic: Restricting and Sorting Data – Sort the rows that are retrieved by a query As data is inserted and updated and indexes keep track of rows, the order in which the rows are stored can change. There is no guarantee that the way Oracle stores the data in your system is in any kind of […]
Continue Reading...Handling Nulls
Null is an unknown value. Null is Schrodinger’s Cat’s state before opening the box. There are ways to deal with null that are unlike anything else in the database, both in concept and in function.
Continue Reading...Using Expressions in a SELECT FROM DUAL
Exam Topic: Retrieving Data Using the SQL SELECT Statement – Execute a basic SELECT statement In The Capabilities of a SELECT Statement, we talked about returning columns from a table using the SELECT list and a few of the alternatives. In fact, any expression you can think of can be in the SELECT list. An expression is “a combination of one […]
Continue Reading...Restricting Data – Selection in the WHERE Clause
Exam Topic: Restricting and Sorting Data – Limit the rows that are retrieved by a query Returning the right data by restricting rows to answer questions is at the heart of SQL Development. As shown in The Capabilities of a SQL SELECT Statement, the WHERE clause is used to specify conditions for which rows should be returned. If the […]
Continue Reading...