Multiple constraints on single column
oracle10g, sql
Solution
You have wrong syntax when create `null_cons` constraint:
Use this (table level check constraint):
CREATE TABLE x(
x VARCHAR2(20),
y NUMBER(2) NOT NULL,
CONSTRAINT fk_cons FOREIGN KEY(x) REFERENCES user_info(user_id),
CONSTRAINT null_cons CHECK(x IS NOT NULL)
)
Or (use `NOT NULL` constraint on column):
CREATE TABLE x(
x VARCHAR2(20) NOT NULL,
y NUMBER(2) NOT NULL,
CONSTRAINT fk_cons FOREIGN KEY(x) REFERENCES user_info(user_id)
)
Or (Use column level check constraint):
CREATE TABLE x(
x VARCHAR2(20) CHECK (X IS NOT NULL),
y NUMBER(2) NOT NULL,
CONSTRAINT fk_cons FOREIGN KEY(x) REFERENCES user_info(user_id)
)
Problem
Can we add multiple constraints on a single column? like- ``` create table x(x varchar2(20), y number(2) not null, constraint fk_cons foreign key(x) references user_info(user_id), constraint null_cons not null(x) ) ``` this query is returning error ora-00904: invalid identifier....