Skip to Main Content
  • Questions
  • What does N in front of value being compared mean?

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Kumud.

Asked: March 20, 2007 - 5:09 pm UTC

Last updated: March 21, 2007 - 7:13 am UTC

Version: 9.2.0.8

Viewed 1000+ times

You Asked

Hello Tom,
I have a query that is behaving differently when N is included or excluded as part of query. One takes longer than the other to execute and has table scans when i explain plan on the query.
The query is a simple query like
Select count(DOC_ID) from DOCUMENT where DOC_ID = 'XXXXX';
This query works as expected where as
Select count(DOC_ID) from DOCUMENT where DOC_ID = N'XXXXX';
causes table scans etc. Both query however give the same result.

What does N in front of where value mean and do to the query?
Thanks
Kumud

and Tom said...

It is data stored using the national character set for your database

http://docs.oracle.com/cd/B19306_01/server.102/b14225/ch2charset.htm#sthref146

the N'string' says 'consider the data in string to be in the character set being used by the national (alternate) character set for my database - not the databases default characterset'

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Kumud Bhattarai, March 21, 2007 - 1:09 pm UTC