0

Following fails to execute

create table product_instance (
  "ID" number(19,0),
  constraint pro_instance_pk primary key ("id")
)

giving the output

SQL Error: ORA-00904: "id": invalid identifier
00904. 00000 -  "%s: invalid identifier"

However the changing "id" to "ID" works fine

create table product_instance (
  "ID" number(19,0),
  constraint pro_instance_pk primary key ("ID")
)

Following also works fine

create table product_instance (
  ID number(19,0),
  constraint pro_instance_pk primary key (id)
)

Appreciate if someone could answer the effect of specifying "ID" instead of just id in the DDL statements. Is oracle case sensitive or insensitive

APC
  • 144,005
  • 19
  • 170
  • 281
Dev Blanked
  • 8,555
  • 3
  • 26
  • 32

2 Answers2

1

When you use quotes, it makes the column name case sensitive. See this question.

Community
  • 1
  • 1
jle
  • 9,316
  • 5
  • 48
  • 67
  • This behaviour is especially nasty when people use reserved words as names for columns or tables... Column-name "exclusive" will not match "EXCLUSIVE", e.g. ... :P – AKDADEVIL Aug 02 '13 at 13:11
-1

Oracle is insensitive in DDL statements. for creating a table we cannot use field name in the ("") double quotes.

 sql>create table product_instance (
     "ID" number(19,0)***,***
      constraint pro_instance_pk primary key ("ID")
      )

This code doesn't execute on the sql promt. and to apply constraints on the table there should not be semicolon in between datatype and constraint.

Mohsin Shaikh
  • 494
  • 1
  • 4
  • 11
  • 1
    Using double-quotes in DDL *makes* Oracle case sensitive. The posted script does run, because that's a comma not a semi-colon; the comma is the correct syntax when defining a table level cronstraint. – APC Aug 02 '13 at 09:36