Question

I need reg_date column value to be generated automatically as current system date.

This statement:

CREATE TABLE medina_student (
  sno      NUMBER(7)              NOT NULL,
  sname    VARCHAR2(20)           NOT NULL,
  dept     VARCHAR2(5)            NOT NULL,
  reg_date DATE DEFAULT 'sysdate' NOT NULL,
  CONSTRAINT sno_pk PRIMARY KEY (sno),
  CONSTRAINT sna_u UNIQUE (sname)
);

produces an error

reg_date date default 'sysdate' not null ,
                      *
ERROR at line 5:
ORA-01858: a non-numeric character was found where a numeric was expected

How to fix it?

Was it helpful?

Solution

The error is indeed in line 5, remove the ':

reg_date date default sysdate not null
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top