Ren
Ren

Reputation: 4683

Time datatype doesn't seems to work

I have the following code for creating a table, but it fails, and I don't know why:

CREATE TABLE Cut_Job
( assembly_id numeric (9, 0),
  dept_no numeric (9, 0),
  process_id numeric (9, 0),
  job_no numeric (9, 0),
  date_commenced date,
  date_completed date,
  machine_type varchar (20),
  machine_time time (0), --this is line 63
  labor_time time (0),
  primary key (dept_no, process_id));

And the error it shows is the following:

Error at Command Line:63 Column:16
Error report:
SQL Error: ORA-00902: invalid datatype
00902. 00000 -  "invalid datatype"
*Cause:    
*Action:

I don't understand why it fails.

Upvotes: 0

Views: 271

Answers (2)

Justin Cave
Justin Cave

Reputation: 231661

It sounds like you want to store an interval in Oracle. time is not a data type that exists in Oracle.

SQL> ed
Wrote file afiedt.buf

  1  CREATE TABLE Cut_Job
  2  ( assembly_id numeric (9, 0),
  3    dept_no numeric (9, 0),
  4    process_id numeric (9, 0),
  5    job_no numeric (9, 0),
  6    date_commenced date,
  7    date_completed date,
  8    machine_type varchar (20),
  9    machine_time interval day to second(0),
 10    labor_time interval day to second(0),
 11*   primary key (dept_no, process_id))
SQL> /

Table created.

Upvotes: 1

user3020494
user3020494

Reputation: 732

The data type is not "time" but

TIMESTAMP

and don't define the length.

Upvotes: 0

Related Questions