Insert multiple records in oracle

前端 未结 3 1979
轻奢々
轻奢々 2020-12-21 16:05

I am using oracle sql developer to insert rows in my database.

While this request is working :

INSERT INTO TABLE ( USERID, USERNAME) VALUES (1,\"ok1\         


        
相关标签:
3条回答
  • 2020-12-21 16:10

    You could use INSERT ALL statement. For example:

    INSERT ALL
      INTO mytable (column1, column2, column3) VALUES ('val1.1', 'val1.2', 'val1.3')
      INTO mytable (column1, column2, column3) VALUES ('val2.1', 'val2.2', 'val2.3')
      INTO mytable (column1, column2, column3) VALUES ('val3.1', 'val3.2', 'val3.3')
    SELECT * FROM dual;
    

    0 讨论(0)
  • 2020-12-21 16:30

    See this recent post for some other ways to enter test data as well: Insert same data multiple times

    0 讨论(0)
  • 2020-12-21 16:35

    Oracle does not support multi-row inserts. You need to write one insert per row:

    INSERT INTO TABLE ( USERID, USERNAME) VALUES (1,'ok1');
    INSERT INTO TABLE ( USERID, USERNAME) VALUES (2,'ok2');
    

    Additionally: string literals need to be enclosed in single quotes in SQL. Double quotes are for identifiers. "ok1" is a column name, 'ok1' is a string constant.

    0 讨论(0)
提交回复
热议问题