Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2014

    Unanswered: Question On Writing SQL Statement

    From the tables that I attached,

    a. Assume Job relation is created. Write the SQL statement that will create the EMP relation (use the structure shown in Table 2)

    Following is my answer:

    Create Table EMP 
    (empnum NUMBER(3), 
    lname VARCHAR2(15) CONSTRAINT emp_lname_nn Not Null, 
    fname VARCHAR2(25), 
    mi CHAR(1), 
    hiredate DATE CONSTRAINT emp_hiredate_nn Not Null, 
    enddate DATE, 
    Jobcode CHAR(3), 
    Salary Number(10,2) 
    CONSTRAINT emp_empnum_pk Primary Key (empnum), 
    CONSTRAINT emp_jobcode_fk Foreign Key (jobcode) REFERENCES Job(job_code);
    b. Write the SQL statement that will enter the first data row into the EMP relation

    Insert into EMP values (101, 'O''Connel', 'John', 'mi', '11-Aug-2000', NULL, '502', 3600)
    For both of this questions, can someone checks with me whether am I doing it correctly? Please point out my mistakes if any, I appreciate your guides.Thank you!
    Attached Thumbnails Attached Thumbnails sep2012q1.JPG  

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    The purpose of TO_DATE is to convert string datatype to DATE datatype.
    With Oracle characters between single quote marks are STRINGS!
    'This is a string, 2009-12-31, not a date'
    When a DATE datatype is desired, then use TO_DATE() function including format.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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