DB Creation   «Prev  Next»

Lesson 12 Use Shared Server to execute SQL statements
Objective Issue a SQL statement from SQL*Plus

Using Shared Server to execute SQL Statements

Now, let’s talk about Oracle Shared Server. Some might say it’s the unsung hero, quietly doing its thing in the background. But can we view it as a conduit to SQL*Plus? Well, let’s put on our creative hats and dive into this delightful analogy.
Imagine Oracle Shared Server as this bustling, swanky cocktail party. It’s posh, it’s efficient, and oh boy, does it know how to handle a crowd! Now, enter SQL*Plus, the charming, slightly old-school guest who’s been attending these parties since who knows when. SQL*Plus is like that guest who knows exactly what they want, a straight-up, no-nonsense interaction with the database. Now, in this glitzy party, you can’t just have every guest (or in our real world, every user session) barging in and demanding the host’s (the database’s) undivided attention. That’s where our suave Oracle Shared Server comes in, acting like the world’s most efficient butler.
Let us say you wish to run a query. Oracle Shared Server says, "Right this way, sir!" And just like that, SQL*Plus is handed off to a shared server process, bypassing the need to have a dedicated server process. It is like skipping the line at the club because you know the DJ.
Now, while SQL*Plus gets to have its fun, running queries and fetching data like there’s no tomorrow, Oracle Shared Server ensures that the database doesn’t get overwhelmed. It’s the ultimate gatekeeper, making sure everyone gets a piece of the action without letting things descend into chaos. To put it in a nutshell, viewing Oracle Shared Server as a conduit to SQL*Plus?
Oracle Shared Server is the digital butler that ensures SQL*Plus gets to schmooze with the database, running its queries and living its best SQL life, all while keeping the party (aka the database) running smoothly. So, dear Oracle DBA, the next time you see Oracle Shared Server in action, tip your hat (virtually, of course) to this magnificent conductor of database interactions, ensuring everyone gets to dance with the data, without stepping on each other’s toes!

Use SQL* Plus to enter and execute a SQL statement

This page discusses how to issue a SQL statement from Shared Server.
In addition to executing the commands that you have already learned about in this module, you can use SQL* Plus to enter and execute any SQL statement. The following example shows a SELECT statement used to retrieve a list of database users:

SQL> SELECT username FROM dba_users;
USERNAME
------------------------------
SYS
SYSTEM
DEMO
DBSNMP
SCOTT
JGENNICK
7 rows selected.
SQL>

Notice that the SQL statement has a semicolon at the end. SQL statements may span multiple lines, so the semicolon is used to tell Server Manager that it has reached the end of the statement. As an alternative to the semicolon, you can also use a forward-slash character to terminate a statement.

Using forwardslash to terminate SQL statements

You can use the forward slash character to terminate an SQL statement as an alternative to the semicolon. Many of the Oracle-supplied DBA scripts use this method. When the forward slash is used, it must be on a line by itself and it must be the first character on that line. The following common query illustrates the use of the forwardslash character. The query retrieves a list of users who are currently logged into the database.

SQL> SELECT username, sid, serial#
2> FROM v$session
3> /

USERNAME      SID     SERIAL#
------------- ---------- ----------
                1          1
                2          1
                3          1
                4          1
                5          1
                6          1
                7         35
                8         35
SYS            11          5

9 rows selected.
SQL>

Using Server Manager - Quiz

Click the quiz link below to take a quiz on using the server manager.
Using SQL Plus - Quiz