DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Need help creating tables

  1. #1
    Join Date
    Feb 2008
    Posts
    1

    Need help creating tables

    Here are the tables I'm trying to create:
    Code:
    CREATE TABLE stores (
    	 strname	VARCHAR2(25),
    	 rrgncode	NUMBER(1),
    	 rgndesc	VARCHAR2(5),
    		CONSTRAINT store_strname_pk PRIMARY KEY(strname));
    
    
    CREATE TABLE employee (
    	 empcode	NUMBER(2),
    	 emptitle	VARCHAR2(4),
    	 emplname	VARCHAR2(25),
    	 empfname	VARCHAR2(25),
    	 empinitial	CHAR(1),
    	 empdob	CHAR(9),
    	 empytdsales	VARCHAR2(12),
    		CONSTRAINT employee_empcode_pk PRIMARY KEY (empcode),
    		CONSTRAINT employee_storename_fk FOREIGN KEY (strname) REFERENCES stores (strname));
    Here is the error I get:
    Code:
    Error starting at line 1 in command:
    CREATE TABLE employee (
    	 empcode	NUMBER(2),
    	 emptitle	VARCHAR2(4),
    	 emplname	VARCHAR2(25),
    	 empfname	VARCHAR2(25),
    	 empinitial	CHAR(1),
    	 empdob	CHAR(9),
    	 empytdsales	VARCHAR2(12),
    		CONSTRAINT employee_empcode_pk PRIMARY KEY (empcode),
    		CONSTRAINT employee_storename_fk FOREIGN KEY (strname) REFERENCES stores (strname))
    Error at Command Line:10 Column:48
    Error report:
    SQL Error: ORA-00904: "STRNAME": invalid identifier
    00904. 00000 -  "%s: invalid identifier"
    *Cause:    
    *Action:
    What on earth am I doing wrong?

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    you dont have a column called strname in your table

  3. #3
    Join Date
    Feb 2008
    Posts
    1
    Thank you. That worked. I am just learning SQL, and our teacher did not cover that, yet expected us to do it on an assignment. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width