Oracle Database bulk inserts & insert date type format conversion

Directly on SQL

The INSERT  ALL 
the INTO  Table (field 1, field 2, field 3) the VALUES (field 1 value, field 2 values, field 3 values)
 the INTO  Table (field 1, field 2, field 3) the VALUES (field 1 value, field 2 values, field value 3)
 the INTO  Table (field 1, field 2, field 3) the vALUES (1 field value, the field value is 2, the value of field 3)
 the SELECT  1  the FROM the DUAL

This section of the SQL above is a sentence, the entire execution

 

About date type, I came across a relatively simple, as long as the conversion just fine

to_date('2002-08-26','yyyy-mm-dd')

 

Example:

- create a table 
the CREATE T_CREATOR ( 
    CREATOR_ID NUMBER ( 32 ) the NOT  NULL , 
    create_user VARCHAR2 ( 30 ), 
    CREATE_TIME DATE, 
    modify_user VARCHAR2 ( 30 ), 
    MODIFY_TIME DATE 
) 
the COMMENT the ON  TABLE T_CREATOR the IS  ' Creator table ' ; 
the COMMENT the ON  the COLUMN CREATOR_ID the IS  ' creator ID ' ; 
the COMMENT the ON  the COLUMNCreate_user the IS  ' Created ' ; 
the COMMENT the ON  the COLUMN CREATE_TIME the IS  ' Created ' ; 
the COMMENT the ON  the COLUMN modify_user the IS  ' Modifier ' ; 
the COMMENT the ON  the COLUMN MODIFY_TIME the IS  ' modified ' ;
 - primary key is created 
the ALTER  TABLE T_CREATOR the ADD  CONSTRAINT PK_T_CREATOR_ID a PRIMARY  KEY ( CREATOR_ID);
- Create a self-energizing sequence of 
the CREATE the SEQUENCE SEQ_T_CREATOR MINVALUE 100  - minimum 100 
NOMAXVALUE - maximum, do not write it has been superimposed on 
the START the WITH  100  - starting value 
INCREMENT BY  1  - growth base 
NOCYCLE - not cycle, has been increased 
NOCACHE; - do not use cache
--创建存储过程
CREATE OR REPLACE FUNCTION GET_SEQ_T_CREATOR RETURN NUMBER IS
  RESULT NUMBER;
BEGIN
  SELECT SEQ_T_CREATOR_ECHO.NEXTVAL INTO RESULT FROM DUAL;
  RETURN(RESULT);
END GET_SEQ_T_CREATOR;
-- 插入数据
INSERT ALL
INTO T_CREATOR(CREATOR_ID,CREATE_USER,CREATE_TIME,MODIFY_USER,MODIFY_TIME) VALUES (GET_SEQ_T_CREATOR 'test',to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss'),'test',to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss'))
T_CREATOR(CREATOR_ID,CREATE_USER,CREATE_TIME,MODIFY_USER,MODIFY_TIME) VALUES (GET_SEQ_T_CREATOR 'test',to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss'),'test',to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss'))
T_CREATOR(CREATOR_ID,CREATE_USER,CREATE_TIME,MODIFY_USER,MODIFY_TIME) VALUES (GET_SEQ_T_CREATOR 'test',to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss'),'test',to_date('2004-05-07 13:23:44', ' YYYY-mm-dd HH24: mi The: SS ' ))
 the SELECT  . 1  the FROM the DUAL; - which is a stored procedure, must write 
- above is a SQL sentence

 

Guess you like

Origin www.cnblogs.com/buyz/p/11366161.html