0

This is homework. I have to create two tables with certain constraints. However, I keep getting syntax errors, and I really have no clue exactly how to format it because there are so many different 'templates' out there. Here is what I have so far.

create table Departments
 (Department_ID number
	PRIMARY KEY,
  Dept_Name varchar2(25)
	NOT NULL UNIQUE,
  City varchar2(50)
	NOT NULL,
  Budget_Code char(5)
	NOT NULL UNIQUE,
  Mailstop char(3)
	NOT NULL);

The constraints are in all caps. Also, I need to know how to do multiple constraints. Can someone help me on this?
The second table I have:

create table Employees
 (Employee_ID number
	PRIMARY KEY,
  Last_Name varchar2(50)
	NOT NULL,
  First_Name varchar2(50)
	NOT NULL,
  State char(2),
  Zipcode char(5),
  e-mail varchar2(100)
	UNIQUE,
  Gender char(1)
	NOT NULL CHECK(Gender="M" OR "F"),
  Hire_Date date
	NOT NULL,
  Department_ID Number
	NOT NULL FOREIGN KEY (Department_ID) references DEPARTMENTS(DEPARTMENT_ID));

If anyone sees errors here, please let me know. I'm still pretty new at this.

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by dan420
1

Oracle does not accepts the "-" sign for the columns. If you want your column to be called e-mail then make it "e-mail".
And your foreign key declaration is not good,

Votes + Comments
agree
0

Okay, thanks. So how should the foreign key declaration go? I followed a template I found, but I guess it may be wrong.

0

here is an example
CREATE TABLE products
( product_id numeric(10) not null,
supplier_id numeric(10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES supplier(supplier_id)
);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.