04-27-14, 01:35 #1Registered User
- 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);
Insert into EMP values (101, 'O''Connel', 'John', 'mi', '11-Aug-2000', NULL, '502', 3600)
04-27-14, 11:35 #2Registered User
Provided Answers: 1
- Join Date
- Aug 2003
- Where the Surf Meets the Turf @Del Mar, CA
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.