Display the sql_id for a query in Oracle 18c

The SET FEEDBACK command has an SQL_ID option to display the sql_id for the currently executed SQL or PL/SQL statements. The sql_id will be assigned to the predefined variable SQL_ID.

Displays the number of records returned by a script when a script selects at least n records. SQL_ID returns the sql_id for the SQL or PL/SQL statements that are executed. The sql_id will be assigned to the predefined variable SQL_ID.

SQL> SET FEEDBACK ON SQL_ID
SQL>  (more...)

SQLcl : Going cold turkey from SQL*Plus

I’m a SQL*Plus junkie. I have loads of scripts that do exactly what I want them to do, so for most tasks I am more productive from the command line than using other tools. If I do find something difficult, I just flick across to SQL Developer or Cloud Control. I’m not a snob about it, but I prefer the command line.

A couple of weeks ago I was playing with the ORDS stuff in (more...)

SQL*Plus tips #8: How to read the output of dbms_output without “serveroutput on”

When “serveroutput” is enabled, SQL*Plus executes “BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;” after each command.
That’s why I don’t like when it is always enabled: it adds extra calls and round-trips and it is inconvenient when I want to get a plan of the last executed query:

SQL> set serverout on;
SQL> select * from dual;

D
-
X

SQL> select * from table(dbms_xplan.display_cursor('','','allstats last'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------
SQL_ID  9babjv8yq8ru3, child number 0

BEGIN  (more...)

Substitutable Columns

Oracle’s substitutable columns are interesting and substantially different than Oracle’s nested tables. The benefit of substitutable columns is that you can create one for an object type or any subtypes of that object type. Unfortunately, you can’t create the same behavior with nested tables because Oracle’s implementation of collection types are always final data types and you can’t extend their behaviors.

The Oracle Database has three types of collections. Two are SQL scoped collection types (more...)

SQLcl – the SQL*Plus plus a plus …

"euphoric: intensely happy or confident", @thatjeffsmith, https://youtu.be/ecgijS76jvw ...

Just watched the video from @thatjeffsmith about SQLcl - and it is, indeed, worth the time. After looking that video, I'm pretty sure that SQLcl will replace SQL*Plus within months (if some more people 'spread the word').

Just a few keywords to make you curious:

  • SQLcl is available as 'standalone' download, but it is also already part of the latest SQLDeveloper 17.2. (more...)

Role of # in SQL*Plus

Uncategorized
| Jul 13, 2017
The # character is for commenting in SQL*Plus, right?

The character # has been mostly used for comments in many languages, such as shell scripts and python. Interestingly # is legal syntax in SQL scripting as well; but is it considered a comment? The answer is no; it's not. The purpose of # in SQL scripts is very different. and you should be very careful using it.

Entering # tells SQL*Plus to temporarily pauses what (more...)

Enough with AFIEDT.BUF

Uncategorized
| Jul 10, 2017
You are in SQL*Plus. You entered a command and urgh, there was a typo. No worries, you bring up the command in an editor by typing:

SQL> ed

This opens up an editor, such as notepad.exe in Windows or vi in Unix, etc. And it puts the last SQL you entered in a file, oddly named, afiedt.buf. You don't like it and you want a name easier to type. Is it possible? Of (more...)

Password Expire

If a user forgets his password, he may ask you to reset it for him. You will then know his new password, which you may see as a security issue. By including the password expire clause in the alter user command, you can force the user to change his password the next time he logs in. After this, you will no longer know his password. The examples which follow show a DBA changing a password (more...)

Using HISTORY in SQL*PLUS 12.2….

One of the biggest things that we couldn’t do in the previous versions of the oracle database was to use the back arrow button-to reexecute the old commands, without typing them. Of course, a workarouns is possible in the form of rlwrap but it’s not comparable to a natively available feature in the SQL*PLUS. Well, until now because now, we have HISTORY option available in 12.2 SQL*PLUS. Let’s take a look.

SQL> /

BANNER                         (more...)

The Oracle Database professional I admire most

Carlos Sierra spent 17 years in the SQL performance group of Oracle Support. He couldn’t move a mountain nor pull down a big oak tree. But Carlos Sierra became a mighty big man by putting all the knowledge he gained during that time into a wonderful tool called “SQLT.”(read more)

Developer Days VM Startup and Shutdown, SQLcl

Uncategorized
| Jun 16, 2016
If you're developing on a remote platform, chances are that you are using a Virtual Machine. (VM)  In Oracle, we release a virtual machine called the  "Oracle Developer Days".    This is available on the Oracle Technology Network and ala google.  Todays hack is setting up headless vm's, ports and aliases to speed up your day. (This post took a lot longer to write that the aliases we set up!)

For this (more...)

Bind Variables

This example, tested on Oracle 11, shows how you can define bind variables in SQL*Plus, assign values to them in PL/SQL then display those values afterwards back in SQL*Plus:

SQL> variable bv1 varchar2(3)
SQL> variable bv2 number
SQL> begin
  2  select 'ABC' into :bv1 from dual;
  3  select 123 into :bv2 from dual;
  4  end;
  5  /

PL/SQL procedure successfully completed.

SQL> print bv1

BV1
--------------------------------
ABC

SQL> print bv2

       (more...)

Using PRELIM Option Of SQL*PLUS….

A recent thread in the Database General Questions place was posted today. The original poster set some wrong values for the database memory related parameters and using those exceptionally large values, database got hung. Well, I don’t know whether that was the real issue or not as the original poster didn’t share the contents of the alert.log file of his database neither shared any other details. What he wanted to know that how he (more...)

SQLcl – Code editing on the console

Uncategorized
| May 1, 2015
We've been playing with our console drawing in SQLcl for a while now and this week, we hooked up some keys to make editing and running much easier.  The video will show the following keys for managing your buffer in the console.  This will make it into the next Early Access candidate soon.

  • up arrow - previous history (this will continue to show you the next history unless you move into the text to edit (more...)

SQLcl connections – Lazy mans SQL*Net completion

Uncategorized
| Apr 30, 2015
Turloch posted this today, which is like aliases for SQL*Net connection URL's which are used to connections like this:

connect <USERNAME>/<Password>@URL


This works great and you can simplify your connection strings that you use.  Vadim wired this into the code completion and we can now code complete via key, a connection string that you have used before or you can set up a new now using the net command.


Connections Types in SQLcl

Uncategorized
| Feb 20, 2015

We support many ways to connect in SQLcl, including lots from SQL*Plus which we need to support to make sure all your SQL*Plus scripts work exactly the same way using SQLcl as with SQL*Plus.

I've added several ways to show how to connect to SQLcl.  If there is one you want to see added that is not here, let me know and I'll add it to the list.  So far, We have below:

Code Insight on SQLcl

Uncategorized
| Feb 19, 2015
Here's a little preview of the code insight we have in SQLcl.  These changes are part of EA2 which are coming out very soon.  This also shows the buffer and cursor management which was introduced in SQLcl


This allows you to move around the buffer easily and add and change text as you would in a normal text editor, not a console window like this.

We're also adding hotkeys to run the buffer from anywhere (more...)

EZCONNECT without a password

After encountering this little annoyance for the nth time, I thought I should write it up once and for all, so it is committed to my electronic memory.

The EZCONNECT naming method is a handy way of connecting to an Oracle database by its service name, which avoids the need for aliases in the TNSNAMES file, or lengthy SQL*Net connection strings :

SQL> connect user/password@hostname:port/service_name
Connected.

However, one would expect that if you don’t want (more...)

SQLCl – LDAP anyone?

since  we released our first preview of SDSQL, we've made  a lot of changes to it and enhanced a lot of things too in there so it would be more useable.  One specific one was the use of LDAP which some customers on SQLDeveloper are using in their organisations as a standard and our first release precluded them from working with this.

Well, to add this, we wanted a way that we could specify the (more...)

SDSQL – Editing Anyone?

Since we dropped our beta out of SQLDeveloper 4.1 and announced SDSQL, we've been busy getting some of the new things out to users.  We support SQL*plus editing straight out of the box, but one thing that was always annoying was the time when you make a mistake and can't fix it to you have finished typing to go back and add a line like this.


This was always the way as console (more...)