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

62⟩ How To Write Text Literals in Oracle?

There are several ways to write text literals as shown in the following samples:

SELECT 'rendc.org' FROM DUAL -- The most common format

rendc.org

SELECT 'It''s Sunday!' FROM DUAL -- Single quote escaped

It's Sunday!

SELECT N'Allo, C''est moi.' FROM DUAL -- National chars

Allo, C'est moi.

SELECT Q'/It's Sunday!/' FROM DUAL -- Your own delimiter

It's Sunday!

 121 views

63⟩ How To Write Numeric Literals in Oracle?

Numeric literals can coded as shown in the following samples:

SELECT 255 FROM DUAL -- An integer

255

SELECT -6.34 FROM DUAL -- A regular number

-6.34

SELECT 2.14F FROM DUAL -- A single-precision floating point

2.14

SELECT -0.5D FROM DUAL -- A double-precision floating point

-0.5

 136 views

64⟩ What Are the ANSI Data Types Supported in Oracle?

The following ANSI data types are supported in Oracle:

* CHARACTER(n) / CHAR(n)

* CHARACTER VARYING(n) / CHAR VARYING(n)

* NATIONAL CHARACTER(n) / NATIONAL CHAR(n) / NCHAR(n)

* NATIONAL CHARACTER VARYING(n) / NATIONAL CHAR VARYING(n) / NCHAR VARYING(n)

* NUMERIC(p,s)

* DECIMAL(p,s)

* INTEGER / INT

* SMALLINT

* FLOAT

* DOUBLE PRECISION

* REAL

 128 views

65⟩ How To Write Date and Time Literals in Oracle?

Date and time literals can coded as shown in the following samples:

SELECT DATE '2002-10-03' FROM DUAL -- ANSI date format

03-OCT-07

SELECT TIMESTAMP '0227-01-31 09:26:50.124' FROM DUAL

31-JAN-07 09.26.50.124000000 AM

-- This is ANSI format

 134 views

66⟩ How To Write Date and Time Interval Literals in Oracle?

Date and time interval literals can coded as shown in the following samples:

SELECT DATE '2002-10-03' + INTERVAL '123-2' YEAR(3) TO MONTH

FROM DUAL

-- 123 years and 2 months is added to 2002-10-03

03-DEC-25

SELECT DATE '2002-10-03' + INTERVAL '123' YEAR(3) FROM DUAL

-- 123 years is added to 2002-10-03

03-OCT-25

SELECT DATE '2002-10-03' + INTERVAL '299' MONTH(3) FROM DUAL

-- 299 months years is added to 2002-10-03

03-SEP-27

SELECT TIMESTAMP '1997-01-31 09:26:50.124'

+ INTERVAL '4 5:12:10.222' DAY TO SECOND(3) FROM DUAL

04-FEB-97 02.39.00.346000000 PM

SELECT TIMESTAMP '1997-01-31 09:26:50.124'

+ INTERVAL '4 5:12' DAY TO MINUTE FROM DUAL

04-FEB-97 02.38.50.124000000 PM

SELECT TIMESTAMP '1997-01-31 09:26:50.124'

+ INTERVAL '400 5' DAY(3) TO HOUR FROM DUAL

07-MAR-98 02.26.50.124000000 PM

SELECT TIMESTAMP '1997-01-31 09:26:50.124'

+ INTERVAL '400' DAY(3) FROM DUAL

07-MAR-98 09.26.50.124000000 AM

SELECT TIMESTAMP '1997-01-31 09:26:50.124'

+ INTERVAL '11:12:10.2222222' HOUR TO SECOND(7) FROM DUAL

31-JAN-97 08.39.00.346222200 PM

 137 views

67⟩ What Are the Limitations Oracle Database 10g XE?

Oracle Database XE is free for runtime usage with the following limitations:

* Supports up to 4GB of user data (in addition to Oracle system data)

* Single instance only of Oracle Database XE on any server

* May be installed on a multiple CPU server, but only executes on one processor in any server

* May be installed on a server with any amount of memory, but will only use up to 1GB RAM of available memory

 121 views

68⟩ How To Convert Numbers to Characters in Oracle?

You can convert numeric values to characters by using the TO_CHAR() function as shown in the following examples:

SELECT TO_CHAR(4123.4570) FROM DUAL

123.457

SELECT TO_CHAR(4123.457, '$9,999,999.99') FROM DUAL

$4,123.46

SELECT TO_CHAR(-4123.457, '9999999.99EEEE') FROM DUAL

-4.12E+03

 134 views

70⟩ How To Download Oracle Database 10g XE?

If you want to download a copy of Oracle Database 10g Express Edition, visit http://www.oracle.com/technology/software/products/database/xe/.

If you are using Windows systems, there are downloads available for you:

* Oracle Database 10g Express Edition (Western European) - Single-byte LATIN1 database for Western European language storage, with the Database Homepage user interface in English only.

* Oracle Database 10g Express Edition (Universal) - Multi-byte Unicode database for all language deployment, with the Database Homepage user interface available in the following languages: Brazilian Portuguese, Chinese (Simplified and Traditional), English, French, German, Italian, Japanese, Korean and Spanish.

* Oracle Database 10g Express Client

You need to download the universal edition, OracleXEUniv.exe, (216,933,372 bytes) and client package, OracleXEClient.exe (30,943,220 bytes).

 122 views

71⟩ How To Convert Characters to Numbers in Oracle?

You can convert characters to numbers by using the TO_NUMBER() function as shown in the following examples:

SELECT TO_NUMBER('4123.4570') FROM DUAL

4123.457

SELECT TO_NUMBER(' $4,123.46','$9,999,999.99') FROM DUAL

4123.46

SELECT TO_NUMBER(' -4.12E+03') FROM DUAL

-4120

 142 views

72⟩ How To Install Oracle Database 10g XE?

To install 10g universal edition, double click, OracleXEUniv.exe, the install wizard starts. It will guide you to finish the installation process. You should take notes about:

* The SYSTEM password you selecte: globalguideline.

* Database server port: 1521.

* Database HTTP port: 8080.

* MS Transaction Server port: 2030.

* The directory where 10g XE is installed: oraclexe

* Hard disk space taken: 1655MB.

 131 views

73⟩ How To Check Your Oracle Database 10g XE Installation?

If you want to check your fresh installation of 10g Express Edition without using any special client programs, you can use a Web browser with this address, http://localhost:8080/apex/.

You will see the login page. Enter SYSTEM as the user name, and the password (globalguideline), you selected during the installation to log into the server.

Visit different areas on your 10g XE server home page to make sure your server is running OK.

You can also get to your 10g XE server home page by going through the start menu. Select All Programs, then Oracle Database 10g Express Edition, and then Go To Database Home Page

 130 views

74⟩ How To Convert Dates to Characters in Oracle?

You can convert dates to characters using the TO_CHAR() function as shown in the following examples:

SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY') FROM DUAL;

-- SYSDATE returns the current date

07-MAY-2006

SELECT TO_CHAR(SYSDATE, 'YYYY/MM/DD') FROM DUAL;

2006/05/07

SELECT TO_CHAR(SYSDATE, 'MONTH DD, YYYY') FROM DUAL;

MAY 07, 2006

SELECT TO_CHAR(SYSDATE, 'fmMONTH DD, YYYY') FROM DUAL;

May 7, 2006

SELECT TO_CHAR(SYSDATE, 'fmDAY, MONTH DD, YYYY') FROM DUAL;

SUNDAY, MAY 7, 2006

 131 views

75⟩ How To Convert Characters to Dates in Oracle?

You can convert dates to characters using the TO_DATE() function as shown in the following examples:

SELECT TO_DATE('07-MAY-2006', 'DD-MON-YYYY') FROM DUAL;

07-MAY-06

SELECT TO_DATE('2006/05/07 ', 'YYYY/MM/DD') FROM DUAL;

07-MAY-06

SELECT TO_DATE('MAY 07, 2006', 'MONTH DD, YYYY')

FROM DUAL;

07-MAY-06

SELECT TO_DATE('May 7, 2006', 'fmMONTH DD, YYYY') FROM DUAL;

07-MAY-06

SELECT TO_DATE('SUNDAY, MAY 7, 2006',

'fmDAY, MONTH DD, YYYY') FROM DUAL;

07-MAY-06

 137 views

76⟩ How To Shutdown Your 10g XE Server?

If you want to shutdown your 10g Express Edition server, go to the Services manager in the control panel. You will a service called OracleServiceXE, which represents your 10g Express Edition server.

Select OracleServiceXE, and use the right mouse click to stop this service. This will shutdown your 10g Express Edition server.

You can also shutdown your 10g XE server through the start menu. Select All Programs, then Oracle Database 10g Express Edition, and then Stop Database.

 130 views

77⟩ How To Convert Times to Characters in Oracle?

You can convert dates to characters using the TO_CHAR() function as shown in the following examples:

SELECT TO_CHAR(SYSDATE, 'HH:MI:SS') FROM DUAL;

04:49:49

SELECT TO_CHAR(SYSDATE, 'HH24:MI:SS.FF') FROM DUAL;

-- Error: SYSDATE has no fractional seconds

SELECT TO_CHAR(SYSTIMESTAMP, 'HH24:MI:SS.FF9') FROM DUAL;

16:52:57.847000000

SELECT TO_CHAR(SYSDATE, 'SSSSS') FROM DUAL;

-- Seconds past midnight

69520

 161 views

78⟩ How To Convert Characters to Times in Oracle?

You can convert dates to characters using the TO_CHAR() function as shown in the following examples:

SELECT TO_CHAR(TO_DATE('04:49:49', 'HH:MI:SS'),

'DD-MON-YYYY HH24:MI:SS') FROM DUAL;

-- Default date is the first day of the current month

01-MAY-2006 04:49:49

SELECT TO_CHAR(TO_TIMESTAMP('16:52:57.847000000',

'HH24:MI:SS.FF9'), 'DD-MON-YYYY HH24:MI:SS.FF9')

FROM DUAL;

01-MAY-2006 16:52:57.847000000

SELECT TO_CHAR(TO_DATE('69520', 'SSSSS'),

'DD-MON-YYYY HH24:MI:SS') FROM DUAL;

01-MAY-2006 19:18:40

 137 views

79⟩ What Is NULL value in Oracle?

NULL is a special value representing "no value" in all data types. NULL can be used on in operations like other values. But most operations has special rules when NULL is involved. The tutorial exercise below shows you some examples:

SET NULL 'NULL'; -- Make sure NULL is displayed

SELECT NULL FROM DUAL;

N

-

N

U

L

L

SELECT NULL + NULL FROM DUAL;

NULL+NULL

----------

NULL

SELECT NULL + 7 FROM DUAL;

NULL+7

----------

NULL

SELECT NULL * 7 FROM DUAL;

NULL*7

----------

NULL

SELECT NULL || 'A' FROM DUAL;

N

-

A

SELECT NULL + SYSDATE FROM DUAL;

NULL+SYSD

---------

NULL

 138 views

80⟩ How To Use NULL as Conditions in Oracle?

If you want to compare values against NULL as conditions, you should use the "IS NULL" or "IS NOT NULL" operator. Do not use "=" or "<>" against NULL. The sample script below shows you some good examples:

SELECT 'A' IS NULL FROM DUAL;

-- Error: Boolean is not data type.

-- Boolean can only be used as conditions

SELECT CASE WHEN 'A' IS NULL THEN 'TRUE' ELSE 'FALSE' END

FROM DUAL;

FALSE

SELECT CASE WHEN '' IS NULL THEN 'TRUE' ELSE 'FALSE' END

FROM DUAL;

TRUE

SELECT CASE WHEN 0 IS NULL THEN 'TRUE' ELSE 'FALSE' END

FROM DUAL;

FALSE

SELECT CASE WHEN NULL IS NULL THEN 'TRUE' ELSE 'FALSE' END

FROM DUAL;

TRUE

SELECT CASE WHEN 'A' = NULL THEN 'TRUE' ELSE 'FALSE' END

FROM DUAL;

-- Do not use "="

FALSE

SELECT CASE WHEN 'A' <> NULL THEN 'TRUE' ELSE 'FALSE' END

FROM DUAL;

-- Do not use "<>"

FALSE

SELECT CASE WHEN NULL = NULL THEN 'TRUE' ELSE 'FALSE' END

FROM DUAL;

-- Do not use "="

FALSE

 154 views