Oracle Database

  Home  Oracle  Oracle Database


“Learn Oracle database programming with hundreds of Interview Questions and Answers and examples and get a better job as an Oracle DBA with this basic and advance Oracle Database Interview Questions and Answers guide”



430 Oracle Database Questions And Answers

41⟩ What Is a Dynamic Performance View in Oracle?

Oracle contains a set of underlying views that are maintained by the database server and accessible to the database administrator user SYS. These views are called dynamic performance views because they are continuously updated while a database is open and in use, and their contents relate primarily to performance. Although these views appear to be regular database tables, they are not. These views provide data on internal disk structures and memory structures. You can select from these views, but you can never update or alter them.

 122 views

42⟩ What Is Input Buffer in SQL*Plus?

Input buffer is a nice feature of the command-line SQL*Plus tool. It allows you to revise a multiple-line command and re-run it with a couple of simple commands. By default, input buffer is always turned on in SQL*Plus. The last SQL statement is always stored in the buffer. All you need is to remember to following commonly used commands:

* LIST - Displays the SQL statement (the last executed SQL statement) in the buffer.

* RUN - Runs the SQL statement in the buffer again. ";" is a quick command equivalent to RUN.

* CLEAR BUFFER - Removes the SQL statement in the buffer.

* INPUT line - Adds a new line into the buffer.

* APPEND text - Appends more text to the last line in the buffer.

* DEL - Deletes one line from the buffer.

* CHANGE /old/new - Replaces 'old' text with 'new' text in the buffer.

 131 views

43⟩ How To Revise and Re-Run the Last SQL Command?

If executed a long SQL statement, found a mistake in the statement, and you don't want enter that long statement again, you can use the input buffer commands to the correct last statement and re-run it. The following tutorial exercise gives you a good example:

SQL> connect HR/retneclgg

SQL> SELECT FIRST_NAME, LAST_NAME, HIRE_DATE

2 FROM EMPLOYEE WHERE FIRST_NAME LIKE 'Joh%';

FROM EMPLOYEE WHERE FIRST_NAME LIKE 'Joh%'

*

ERROR at line 2:

ORA-00942: table or view does not exist

SQL> LIST

1 SELECT FIRST_NAME, LAST_NAME, HIRE_DATE

2* FROM EMPLOYEES WHERE FIRST_NAME LIKE 'Joh%'

SQL> CHANGE /EMPLOYEE/EMPLOYEES/

2* FROM EMPLOYEES WHERE FIRST_NAME LIKE 'Joh%'

SQL> RUN

(Query output)

SQL> INPUT ORDER BY FIRE_DATE

SQL> LIST

1 SELECT FIRST_NAME, LAST_NAME, HIRE_DATE

2 FROM EMPLOYEE WHERE FIRST_NAME LIKE 'Joh%'

3* ORDER BY HIRE_DATE

SQL> RUN

(Query output)

SQL> CLEAR BUFFER

buffer cleared

SQL> LIST

SP2-0223: No lines in SQL buffer.

 162 views

44⟩ What Is a Recycle Bin in Oracle?

Recycle bin is a logical storage to hold the tables that have been dropped from the database, in case it was dropped in error. Tables in recycle bin can be recovered back into database by the Flashback Drop action. Oracle database recycle save the same purpose as the recycle bin on your Windows desktop.

Recycle bin can be turned on or off in the recyclebin=on/off in your parameter file.

 137 views

45⟩ What Is Oracle?

Oracle is a company. Oracle is also a database server, which manages data in a very structured way. It allows users to store and retrieve related data in a multiuser environment so that many users can concurrently access the same data. All this is accomplished while delivering high performance. A database server also prevents unauthorized access and provides efficient solutions for failure recovery.

 115 views

46⟩ How Run SQL*Plus Commands That Are Stored in a Local File?

If you have a group of commands that you need to run them repeatedly every day, you can save those commands in a file (called SQL script file), and using the "@fileName" command to run them in SQL*Plus. If you want to try this, create a file called empinput.sql with:

SELECT 'Welcome to' FROM DUAL;

SELECT 'rendc.org!' FROM DUAL;

Then run the "@" command in SQL*Plus as:

SQL> connect HR/retneclgg

SQL> @ empinput.sql

'WELCOMETO

----------

Welcome to

'globalguideline.COM

--------------

rendc.org!

 144 views

47⟩ What Is SQL*Plus?

SQL*Plus is an interactive and batch query tool that is installed with every Oracle Database Server or Client installation. It has a command-line user interface, a Windows Graphical User Interface (GUI) and the iSQL*Plus web-based user interface.

 139 views

48⟩ How To Use SQL*Plus Built-in Timers?

If you don't have a stopwatch/timer and want to measure elapsed periods of time, you can SQL*Plus Built-in Timers with the following commands:

* TIMING - Displays number of timers.

* TIMING START [name] - Starts a new timer with or without a name.

* TIMING SHOW [name] - Shows the current time of the named or not-named timer.

* TIMING STOP [name] - Stops the named or not-named timer.

The following tutorial exercise shows you a good example of using SQL*Plus built-in timers:

SQL> TIMING START timer_1

(some seconds later)

SQL> TIMING START timer_2

(some seconds later)

SQL> TIMING START timer_3

(some seconds later)

SQL> TIMING SHOW timer_1

timing for: timer_2

Elapsed: 00:00:19.43

(some seconds later)

SQL> TIMING STOP timer_2

timing for: timer_2

Elapsed: 00:00:36.32

SQL> TIMING

2 timing elements in use

 136 views

49⟩ What Is Oracle Server Autotrace in Oracle?

Autotrace is Oracle server feature that generates two statement execution reports very useful for performance tuning:

* Statement execution path - Shows you the execution loop logic of a DML statement.

* Statement execution statistics - Shows you various execution statistics of a DML statement.

To turn on the autotrace feature, the Oracle server DBA need to:

* Create a special table called PLAN_TABLE.

* Create a special security role called PLUSTRACE.

* Grant PLUSTRACE role your user account.

 135 views

50⟩ How To Set Up Autotrace for a User Account?

If an Oracle user wants to use the autotrace feature, you can use the tutorial as an example to create the required table PLAN_TABLE, the required security role PLUSTRACE, and grant the role to that user:

SQL> CONNECT HR/retneclgg

SQL> @oraclexeapporacleproduct10.2.0server

RDBMSADMINUTLXPLAN.SQL

Table (HR.PLAN_TABLE) created.

SQL> CONNECT / AS SYSDBA

SQL> @C:oraclexeapporacleproduct10.2.0server

SQLPLUSADMINPLUSTRCE.SQL

SQL> drop role plustrace;

Role (PLUSTRACE) dropped.

SQL> create role plustrace;

Role (PLUSTRACE) created.

SQL> grant plustrace to dba with admin option;

Grant succeeded.

SQL> GRANT PLUSTRACE TO HR;

Grant succeeded.

Remember that PLAN_TABLE table must be created under the user schema HR.

 141 views

51⟩ How To Get Execution Path Reports on Query Statements?

If your user account has autotrace configured by the DBA, you can use the "SET AUTOTRACE ON EXPLAIN" command to turn on execution path reports on query statements. The tutorial exercise bellow shows you a good example:

SQL> CONNECT HR/retneclgg

SQL> SET AUTOTRACE ON EXPLAIN

SQL> SELECT E.LAST_NAME, E.SALARY, J.JOB_TITLE

2 FROM EMPLOYEES E, JOBS J

3 WHERE E.JOB_ID=J.JOB_ID AND E.SALARY>12000;

LAST_NAME   SALARY JOB_TITLE

----------------- ---------- -----------------------------

King 24000 President

Kochhar 17000 Administration Vice President

De Haan 17000 Administration Vice President

Russell 14000 Sales Manager

Partners 13500 Sales Manager

Hartstein 13000 Marketing Manager

6 rows selected.

 158 views

52⟩ How To Get Execution Statistics Reports on Query Statements?

If your user account has autotrace configured by the DBA, you can use the "SET AUTOTRACE ON STATISTICS" command to turn on execution statistics reports on query statements. The tutorial exercise bellow shows you a good example:

SQL> CONNECT HR/retneclgg

SQL> SET AUTOTRACE ON STATISTICS

SQL> SELECT E.LAST_NAME, E.SALARY, J.JOB_TITLE

2 FROM EMPLOYEES E, JOBS J

3 WHERE E.JOB_ID=J.JOB_ID AND E.SALARY>12000;

LAST_NAME   SALARY JOB_TITLE

----------------- ---------- -----------------------------

King 24000 President

Kochhar 17000 Administration Vice President

De Haan 17000 Administration Vice President

Russell 14000 Sales Manager

Partners 13500 Sales Manager

Hartstein 13000 Marketing Manager

6 rows selected.

 139 views

53⟩ What Is SQL in Oracle?

SQL, SEQUEL (Structured English Query Language), is a language for RDBMS (Relational Database Management Systems). SQL was developed by IBM Corporation.

 126 views

55⟩ What Are the Oracle Built-in Data Types?

There are 20 Oracle built-in data types, divided into 6 groups:

* Character Datatypes - CHAR, NCHAR, NVARCHAR2, VARCHAR2

* Number Datatypes - NUMBER, BINARY_FLOAT, BINARY_DOUBLE

* Long and Row Datatypes - LONG, LONG RAW, RAW

* Datetime Datatypes - DATE, TIMESTAMP, INTERVAL YEAR TO MONTH, INTERVAL DAY TO SECOND

* Large Object Datatypes - BLOB, CLOB, NCLOB, BFILE

* Row ID Datatypes - ROWID, UROWID

 125 views

56⟩ What Are the Differences between CHAR and NCHAR in Oracle?

Both CHAR and NCHAR are fixed length character data types. But they have the following differences:

* CHAR's size is specified in bytes by default.

* NCHAR's size is specified in characters by default. A character could be 1 byte to 4 bytes long depending on the character set used.

* NCHAR stores characters in Unicode.

 116 views