我可能在这里犯了一个菜鸟错误,但是当我尝试插入新数据时,我得到了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');
我在做什么错?任何见解都会有所帮助。
答案 0 :(得分:1)
在声明末尾添加此内容:
SELECT * FROM dual
ORA-00928
的意思是“缺少SELECT关键字”。 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
答案 1 :(得分:0)
Year_founded
列必须是INT类型的列,因此请勿使用''
在INT类型列中插入值时。
在末尾添加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;
答案 2 :(得分:0)
完整脚本(';'应在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 * from dual;