Reputation: 1
create table Funkcje
(
nazwa_funkcji varchar(15) constraint funk_pk PRIMARY KEY,
min_myszy number(5) funk_min_nn NOT NULL,
max_myszy number(5) funk_max_nn NOT NULL,
constraint funk_ch check(min_myszy < max_myszy)
)
I am getting an error while creating Table Orders:
ORA-00907 - "missing right parenthesis"
Upvotes: 0
Views: 1184
Reputation: 52923
If you want to name a NOT NULL constraint in line you need to use the constraint keyword as with every other type of constraint
create table Funkcje
(
nazwa_funkcji varchar(15) constraint funk_pk PRIMARY KEY,
min_myszy number(5) constraint funk_min_nn NOT NULL,
max_myszy number(5) constraint funk_max_nn NOT NULL,
constraint funk_ch check(min_myszy < max_myszy)
)
This returns the following in the data dictionary
SQL> select constraint_name, constraint_type, search_condition_vc
2 from user_constraints
3 where table_name = 'FUNKCJE';
CONSTRAINT_NAME C SEARCH_CONDITION_VC
-------------------- - -----------------------
FUNK_MIN_NN C "MIN_MYSZY" IS NOT NULL
FUNK_MAX_NN C "MAX_MYSZY" IS NOT NULL
FUNK_CH C min_myszy < max_myszy
FUNK_PK P
Also, although varchar and varchar2 are identical Oracle doesn't guarantee that the current behaviour of varchar will continue (it's been the same for a very long time though). It would be more usual to use varchar2. The documentation says:
Do not use the VARCHAR data type. Use the VARCHAR2 data type instead. Although the VARCHAR data type is currently synonymous with VARCHAR2, the VARCHAR data type is scheduled to be redefined as a separate data type used for variable-length character strings compared with different comparison semantics.
Upvotes: 3