我在使用Oracle XE 11G时会遇到此错误我已经选择了2个小时,似乎找不到语法错误所在的位置。
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
单引号用于字符串文字。
您需要使用双引号"
(对于案例敏感的命名),或根本没有引号(不敏感)。
删除引号,并在创建表之后将评论移至自己的语句中:
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';