Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not add table constraint for sdate >= bdate in Oracle
    primarykey
    data
    text
    <p>Here's the table schema:</p> <pre><code>create table EMPLOYEE (fname /* Employee's first name */ varchar(15) not null, init /* Employee's middle initial */ char(1), lname /* Employee's last name */ varchar(15) not null, IRD /* Employee's IRD number */ varchar(10) not null primary key, sex /* Employee's sex */ char(1) constraint check_sex check (sex in ('f','m','F','M')), bdate /* Employee's birthdate */ date, office /* Employee's office */ varchar(5), reg_org /* The number of the registration office the employee works for */ varchar(10), sdate /* Starting date in the organization */ date); </code></pre> <p>Then I think it make sense to add the constraint</p> <pre><code>alter table employee add constraint ck_date check (sdate &gt;= bate); </code></pre> <p>but it gives me an error</p> <pre><code>add constraint ck_date check (sdate &gt;= bdate) * ERROR at line 2: ORA-02293: cannot validate (SYSTEM.CK_DATE) - check constraint violated </code></pre> <p>Anyone know where I go wrong?</p> <hr> <p>update the data of the two columns</p> <p>SQL> select bdate, sdate from employee;</p> <pre><code>BDATE SDATE --------- --------- 21-JAN-58 22-FEB-10 21-MAY-70 17-MAR-09 09-NOV-47 12-MAY-08 10-OCT-53 15-JUN-09 01-OCT-56 01-OCT-05 </code></pre> <hr> <pre><code>SQL&gt; select to_char(bdate, 'yyyy-mm-dd') as bdate, to_char(sdate,'yyyy-mm-dd') from employee; BDATE TO_CHAR(SD ---------- ---------- 1958-01-21 2010-02-22 1970-05-21 2009-03-17 2047-11-09 2008-05-12 1953-10-10 2009-06-15 1956-10-01 2005-10-01 </code></pre> <hr> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload