ORA-00907错误求助:排查CREATE TABLE语句语法问题
Fixing Your ORA-00907 Error in the CREATE TABLE Statement
Hey there, I see you've been stuck on this ORA-00907 error for an hour—let's get this sorted out quickly!
The root cause here is how you're using the LONG data type in your table definition. Here's the breakdown:
- Oracle's
LONGtype does not accept a length parameter (the numbers in parentheses like(10000)are invalid here). - Even worse,
LONGis a deprecated type in Oracle—Oracle recommends usingCLOBfor large text data instead. But wait, looking at your field names (travel_allowance, housing_allowance, PF, etc.), these are all numeric values (salary components), so using a numeric data type likeNUMBERmakes way more sense than any text type!
Here's the corrected CREATE TABLE statement tailored to your use case:
CREATE TABLE salary_details ( emp_id NUMBER(2), travel_allowance NUMBER(10, 2), -- 10 digits total, 2 for cents (adjust precision as needed) housing_allowance NUMBER(12, 2), PF NUMBER(12, 2), account_no NUMBER(15), -- If account numbers need leading zeros preserved, use VARCHAR2(20) instead Total_sal NUMBER(12, 2) );
A quick note on account_no: If your account numbers might include leading zeros that need to stay intact (like some bank account formats), swap NUMBER(15) with VARCHAR2(20)—numeric types automatically drop leading zeros, which could break your data integrity.
If you ever do need to store large text data in the future, remember to use CLOB instead of LONG, like this:
some_large_text_field CLOB
内容的提问来源于stack exchange,提问作者Humaid Kidwai
相关产品推荐
相关产品推荐

