View Poll Results: Expressin in Primary Field
- 2. You may not vote on this poll
Expression in Primary Key
I'm having problem in creation of primary key.
CREATE TABLE DB_SIZE
( INSTANCE_NAME VARCHAR2(8) NOT NULL,
DB_DATE DATE NOT NULL,
DATABASE_SIZE NUMBER(12,2) NOT NULL,
DB_ACTUALSIZE NUMBER(12,2) NOT NULL
ALTER TABLE DB_SIZE
ADD CONSTRAINT PR_INST_DBDATE PRIMARY KEY (INSTANCE_NAME,TO_CHAR(DB_DATE,'YYYYMMDD'))
PRIMARY KEY (INSTANCE_NAME,TO_CHAR(DB_DATE,'YYYYMMDD'))
ERROR at line 3:
ORA-00907: missing right parenthesis
First I can use expression in primary key or not..?
If yes What's wrong in SQL.
No, you can't use an expression in a primary key.
What i think you are looking for here is a primary key defined on ...
...and a separate check constraint on db_date to say ...
Click Here to Expand Forum to Full Width