sql - Creating Table (Oracle) -


i creating 2 tables. first table creates no errors, when try create subhead table, error: line 2, missing right parenthesis. not sure wrong line. below sql statements:

create table head    (code numeric(4,0) not null primary key,     headname varchar(50) not null unique,     htype varchar(1) not null,     hdate date not null,     opbal decimal(11,2) not null    );  create table subhead    (hcode numeric(4,0) not null foreign key references head(code),     subcode numeric(4,0) not null,     subname varchar(50) not null,     sdate date not null,     opbal decimal (11,2) not null,     constraint pk_subheadid primary key (hcode, subcode)    ); 

syntax: http://docs.oracle.com/cd/b28359_01/server.111/b28286/clauses002.htm#sqlrf52167
note "in-line" constraint syntax : "col col_type references tab(col)" , not "foreign key"

the data type number number not numeric

so memory did not fool me - can have multiple in-line constraints (although syntax graph doesn't show it):

sql> create table tt1(a number primary key);  table created.  sql> create table tt2(a number references tt1(a) not null);  table created. 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -