ALTER TABLE(添加新列)不起作用

时间:2015-11-17 21:47:59

标签: sql oracle sql-update alter

说明:向Nonappliance添加一个名为ON_HAND_VALUE的列,其中包含一个7位,两位小数,并将所有值设置为ON_HAND_VALUE为ON_HAND * PRICE。

最后两行/命令给出了错误“列名或提供的值的数量与表定义不匹配”。我不知道我做错了什么。请有人帮帮我:(

CREATE TABLE NONAPPLIANCE
(
    PART_NUM CHAR(4) PRIMARY KEY NOT NULL,
    DESCRIPTION CHAR(15),
    ON_HAND DECIMAL(4,0),
    CLASS CHAR(2),
    PRICE DECIMAL(6,2) 
);

INSERT INTO NONAPPLIANCE 
    SELECT 
        PART_NUM, DESCRIPTION, ON_HAND, CLASS, PRICE 
    FROM 
        Part 
    WHERE 
        CLASS != 'AP';

UPDATE NONAPPLIANCE 
SET DESCRIPTION = 'Steam Iron' 
WHERE PART_NUM = 'AT94';

UPDATE NONAPPLIANCE 
SET PRICE = PRICE * 1.03 
WHERE CLASS = 'SG';

INSERT INTO NONAPPLIANCE 
VALUES ('TL92', 'Edge Trimmer', '11', 'HW', 29.95);

DELETE FROM NONAPPLIANCE 
WHERE CLASS = 'SG';

UPDATE NONAPPLIANCE 
SET CLASS = NULL 
WHERE PART_NUM = 'FD21';

ALTER TABLE NONAPPLIANCE 
    ADD ON_HAND_VALUE DECIMAL(7,2);

UPDATE NONAPPLIANCE 
SET ON_HAND_VALUE = PRICE * ON_HAND;

0 个答案:

没有答案