0

I'm, new to SQL. I have created few tables:

CREATE TABLE MAINTINANCE
(Maint_mname char(10),
Maint_date date,
Maint_duedate date NOT NULL,
Maint_mdesc char (15));    

CREATE TABLE DESIGNERR
(Dez_emp_number varchar(11),
Dez_field char(12),
Dez_qualification char(10) NOT NULL,
Dez_experience smallint);

For the first table I am adding the following constraint:

ALTER TABLE MAINTINANCE ADD CONSTRAINT CHK_maintdate CHECK(Maint_date<MAint_duedate);

but I am getting the error invalid ALTER TABLE option. Could you please let me know why this is appearing? The same is working for a friend but not for me.

For the second table I have to write a SQL command for the business rule:

If the Qualification of a Designer is BS then a Minimum of 4 years Experience is required. But, if the Qualification of the Designer is MS then a Minimum of 2 years Experience is sufficient.

How can we define this business rule in SQL?

Justin Cave
  • 227,342
  • 24
  • 367
  • 384
user1804219
  • 1
  • 1
  • 2
  • 4
    Hi and welcome to Stack Overflow! Your first problem is a spelling mistake; that would not work for your friend either. How do you think you should code the business rule? [What have _you_ tried](http://mattgemmell.com/2008/12/08/what-have-you-tried/)? It's polite to show some effort yourself and no-one will be able to show you where you're going wrong if you don't post your code. – Ben Nov 06 '12 at 20:01

1 Answers1

3

The code you posted works

SQL> CREATE TABLE MAINTINANCE
  2  (Maint_mname char(10),
  3  Maint_date date,
  4  Maint_duedate date NOT NULL,
  5  Maint_mdesc char (15));

Table created.

SQL> ALTER TABLE MAINTINANCE ADD CONSTRAINT CHK_maintdate CHECK(Maint_date<MAint_duedate);

Table altered.

If you're getting an error,

  • Cut and paste from a SQL*Plus session that shows exactly what statements you are executing
  • Post the full error stack

Although it does not affect your code, the word "MAINTINANCE" is misspelled. It should be "Maintenance". Future human developers will be grateful if your table names are spelled correctly.

Justin Cave
  • 227,342
  • 24
  • 367
  • 384