2017-02-22 49 views
0

我在使用Oracle XE 11g時遇到此錯誤 我一直在選擇2小時,似乎無法找到語法錯​​誤所在。SQL語法錯誤| ORA-00904::無效的標識符

CREATE TABLE vacation_unit 
 
('VACATION_ID' INT NOT NULL COMMENT 'Vacation ID primary key', 
 
    'LOCATION_NUM' INT NULL COMMENT 'Location Number', 
 
    'UNIT_NUM' INT NULL COMMENT 'Unit Number in Condo building', 
 
    'SQR_FT' DECIMAL (5,0) NULL COMMENT 'Size of COONDO unit in square feet', 
 
    'BDRMS' DECIMAL (2,0) NULL COMMENT 'Number of bedrooms in CONDO', 
 
    'BATHS' DECIMAL (2,0) NULL COMMENT 'Number of bathrooms', 
 
    'VACATION_FEE' DECIMAL (6,2) NULL COMMENT 'Monthly condo fee', 
 
    'OWNER_NUM' CHAR(5) NULL COMMENT 'Number of CONDO owner', 
 
    PRIMARY KEY ('VACATION_ID'));

我用網上那些語法檢查器和第二線不斷得到凸顯,但如果我刪除線,然後強調了繼續它的行。這使我相信代碼的整個結構有問題。 任何人都在意協助?

非常感謝, Xlar

回答

1

刪除引號和表創建後移動的評論對自己的發言:

CREATE TABLE vacation_unit(
    VACATION_ID INT   NOT NULL, 
    LOCATION_NUM INT   NULL, 
    UNIT_NUM  INT   NULL, 
    SQR_FT  DECIMAL (5,0) NULL, 
    BDRMS  DECIMAL (2,0) NULL, 
    BATHS  DECIMAL (2,0) NULL, 
    VACATION_FEE DECIMAL (6,2) NULL, 
    OWNER_NUM CHAR(5)  NULL, 
    PRIMARY KEY (VACATION_ID) 
); 

COMMENT ON COLUMN vacation_unit.vacation_id IS 'Vacation ID primary key'; 
COMMENT ON COLUMN vacation_unit.location_num IS 'Location Number'; 
COMMENT ON COLUMN vacation_unit.unit_num  IS 'Unit Number in Condo building'; 
COMMENT ON COLUMN vacation_unit.sqr_ft  IS 'Size of COONDO unit in square feet'; 
COMMENT ON COLUMN vacation_unit.bdrms  IS 'Number of bedrooms in CONDO'; 
COMMENT ON COLUMN vacation_unit.baths  IS 'Number of bathrooms'; 
COMMENT ON COLUMN vacation_unit.vacation_fee IS 'Monthly condo fee'; 
COMMENT ON COLUMN vacation_unit.owner_num IS 'Number of CONDO owner'; 
2

單引號是字符串文字。

您需要使用雙引號"(區分大小寫的命名)或根本不引號(不區分大小寫)。

+2

@Xlar - 而且,如果你表現最好是「好像」列名雙引號不要甚至不存在。不要使用需要雙引號的列名(這包括列名,這些列名是保留的Oracle字,列名以數字開頭或包含非下劃線以外的非字母,非數字符號以及區分大小寫的名稱)列名那需要雙引號只會給數據庫和查詢帶來麻煩。 – mathguy