Useful little things and queries that may be useful with their description. 1. Get a list of all fields of the table that interests us. select column_name from user_tab_columns where upper(table_name) = upper('table_name') 2. Change the default date format in the session. ...
A function for calculating the check digit of the EAN13 barcode based on the first 12 digits. Input: a string (12-digit number). Output: the check digit. function GetControlNumber(p_code varchar2) return number is v…
Let's start with the RANK() function. With explanations for what it is and in what cases it may be useful. The RANK() function is a very useful function that allows us to number a set by some grouping value within the entire selected set. It is easiest to show this with an example. To do this, let's create a small table:
Learn how much each Tablespace occupies: (Size is shown in megabytes) select a.tablespace_name, totalspace, nvl(freespace,0) freespace, (totalspace-nvl(freespace,0)) used, ((totalspace-nvl(freespace,0))/totalspace)*100 "%USED" from (select a.tablespace_name, sum(a.bytes) totalspace, sum(b.bytes) freespace from dba_data_files a, dba_free_space b where a.tablespace_name = b.tablespace_name group by a.tablespace_name)
This publication explains how to work with specific methods that are present in the Oracle database, for working with Trees. So, let's get started... --Creating a table for experimenting with trees. create table my_tree ( id nu…
A simple email address check looks like this: select * from EMailsTable et where REGEXP_LIKE (et.Email, '[A-z0-9._%-]+@[A-z0-9._%-]+\.[A-z]{2,4}') The script selects from the table with email addresses only those addresses that match the specified regular expression.
For those who have switched from MSSQL to Oracle, like me, it's very uncomfortable to lack such a convenient construction as: select * into #tmp from table1 Where #tmp - temporary table, with which we can further address within the session as with a normal one...
It's no secret that when using DISTINCT with SELECT, we get a set of unique records, but it turns out in Oracle, there is another operator for this purpose UNIQUE - and, as experiments have shown, it seems to provide better performance.
Get Oracle Version SELECT * FROM V$VERSION