我得到ora-00928试图插入新数据

rdrgkggo  于 2021-07-24  发布在  Java
关注(0)|答案(3)|浏览(298)

我可能在这里犯了一个新手错误,但是当我尝试插入新数据时,我得到了ora-00928错误代码。看一看:

INSERT ALL
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'GLOCK', '1982', 'PISTOLS', 'AUSTRIA')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BERETTA', '1526', 'PISTOLS', 'ITALY')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'SMITH AND WESSON', '1856', 'PISTOLS', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'MOSSBERG', '1919', 'SHOTGUNS', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BENELLI', '1967', 'SHOTGUNS', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BROWNING', '1878', 'SHOTGUNS', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'WINCHESTER', '1866', 'RIFLES', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BUSHMASTER', '1973', 'RIFLES', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'REMINGTON', '1816', 'RIFLES', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'KLASHNIKOV', '1807', 'RIFLES', 'UNITED STATES');

我做错什么了?任何见解都会有帮助。

vfwfrxfs

vfwfrxfs1#

在陈述的结尾加上:

SELECT * FROM dual
``` `ORA-00928` 表示“缺少选择关键字”。这个 `INSERT ALL` 语句需要它,所以它的形式是:

INSERT ALL
INTO t1 (col1, col2, ...) VALUES (val1, val2, ...)
INTO t1 (col1, col2, ...) VALUES (val1, val2, ...)
INTO t1 (col1, col2, ...) VALUES (val1, val2, ...)
SELECT * FROM dual

e0uiprwp

e0uiprwp2#

完整脚本(';'应在双后)

INSERT ALL
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'GLOCK', '1982', 'PISTOLS', 'AUSTRIA')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BERETTA', '1526', 'PISTOLS', 'ITALY')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'SMITH AND WESSON', '1856', 'PISTOLS', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'MOSSBERG', '1919', 'SHOTGUNS', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BENELLI', '1967', 'SHOTGUNS', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BROWNING', '1878', 'SHOTGUNS', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'WINCHESTER', '1866', 'RIFLES', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BUSHMASTER', '1973', 'RIFLES', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'REMINGTON', '1816', 'RIFLES', 'UNITED STATES')
INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'KLASHNIKOV', '1807', 'RIFLES', 'UNITED STATES')
select * from dual;
t1rydlwq

t1rydlwq3#

Year_founded 列必须是int类型的列,因此不要使用 '' 在int type列中插入值时。
添加 SELECT * FROM DUAL 最后。
下面是一个使用您的查询的示例:

INSERT ALL
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'GLOCK', 1982, 'PISTOLS', 'AUSTRIA')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BERETTA', 1526, 'PISTOLS', 'ITALY')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'SMITH AND WESSON', 1856, 'PISTOLS', 'UNITED STATES')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'MOSSBERG', 1919, 'SHOTGUNS', 'UNITED STATES')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BENELLI', 1967, 'SHOTGUNS', 'UNITED STATES')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BROWNING', 1878, 'SHOTGUNS', 'UNITED STATES')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'WINCHESTER', 1866, 'RIFLES', 'UNITED STATES')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'BUSHMASTER', 1973, 'RIFLES', 'UNITED STATES')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'REMINGTON', 1816, 'RIFLES', 'UNITED STATES')
    INTO MANUFACTURER ( MANUFACTURER_ID, NAME, YEAR_FOUNDED, SPECIALTY, ORIGIN)
    VALUES (MANUFACTURER_ID_SEQ.NEXTVAL, 'KLASHNIKOV', 1807, 'RIFLES', 'UNITED STATES')

    SELECT 1 FROM DUAL;

相关问题