CHIL-ORACLE-给表插入数据
1.插入数据语法 INSERT INTO [schema.]{table | view | subquery }[@dblink] [(column [, column] ...) ] {VALUES (expr [, expr] ...) | subquery} [WHERE condition] 2.插入单行 --例如: INSERT INTO DEPARTMENT (DEPARTMENT_ID,NAME,LOCATION_ID) VALUES (01,’COMPUTER’,167) 3.插入多行 将SELECT语句检索出来的所有数据行都插入到表中.这条语句通常在从一个表向另一个表快速复制数据行. --例如: INSERT INTO ORDER_TEMP SELECT A.ORDER_ID,B.ITEM_ID,C.NAME,E.FIRST_NAME||'.'||E.LAST_NAME,A.ORDER_DATE,A.SHIP_DATE,D.DESCRIPTION,B.ACTUAL_PRICE,B.QUANTITY,B.TOTAL FROM SALES_ORDER A, ITEM B, CUSTOMER C, PRODUCT D, EMPLOYEE E WHERE MONTHS_BETWEEN(TO_DATE(A.ORDER_DATE),TO_DATE('01-7月-91'))>0 AND A.CUSTOMER_ID=C.CUSTOMER_ID AND C.SALESPERSON_ID=E.EMPLOYEE_ID AND A.ORDER_ID=B.ORDER_ID AND B.PRODUCT_ID=D.PRODUCT_ID 4.利用语句块循环插入百万条数据 --创建表: create table kiki_test00( id number(10) primary key, name varchar2(20), password varchar2(50), time date ); --创建约束 create sequence seq_kiki_test00; --循环插入100万数据 declare v_no number:=0; v_count number:=100; v_no_first number:=1; v_no_last number:=100000; begin for i in v_no_first .. v_no_last loop insert into kiki_test00 values( seq_kiki_test00.nextval, dbms_random.string('a',5), dbms_random.string('a',10), sysdate ); v_no:=v_no+1; if v_no>=v_count then commit; v_no:=0; end if; end loop; end; /