oracle insert into values batch insert

method one

#oracleMultiple insertioninsert all

xxxxx

select 1 from dual;

Method 2

insert into tableName(column1(主键),column2,column3...)
  select value1 column1,value2 column2,value3 column3 from dual
  union all
  select value1 column1,value2 column2,value3 column3 from dual
  union all
  select value1 column1,value2 column2,value3 column3 from dual
  union all
  select value1 column1,value2 column2,value3 column3 from dual

 

Method three

begin
  insert into oracle_table ( id, code ) values( 1 , '1' );  
  insert into oracle_table ( id, code ) values( 2 , '2' );  
  insert into oracle_table ( id, code ) values( 3 , '3' );   
  insert into oracle_table ( id, code ) values( 4 , '4' );
end;

 

I took some notes recently

#Switch page
su#Switch root
mkdir -p /opt/oracledbfile #Create file
chmod -R 777 /opt/oracledbfile/ #Authorization

#Create tablespace
 create tablespace mydemo datafile '/opt/oracledbfile/mydemo.dbf' 
    size 200m autoextend on next 50m maxsize 20480m;
#Create account password
create user cm identified by ok default tablespace mydemo;
#Authorize
grant connect,resource to cm;
#ok
conn cm/ok

# Query the oracle table
 cd "/root"
 su oracle
sqlplus
select * from userinfos;

#oracle multiple insert insert all xxxxx select 1 from dual;

Add keyProperty="id" useGeneratedKeys="true" to #mapper

#can get the id

#serverTimezone = GMT%2b8Adjust time zone

#useGeneratedKeys The value range is true and false. The default value is: false. Meaning: Set whether to use JDBC's getGenereatedKeys method to obtain the primary key and assign it to the domain model attribute set by keyProperty.

keyProperty takes the key value of the id, mainly when the primary key is auto-incremented. After the addition is successful, the primary key value can be used directly. The value of keyProperty is the attribute value of the object, not the field name in the database table.

#Connect to the database
su oracle 
sqlplus
cm
ok
desc uesrinfos;
#Metadata int type (38) bits will appear          
#varchar2(20) bits will automatically handle utf-8 characters
#select max(userid),username,min(birthday) from uesrinfos group by username; When grouping, sorting rules must be defined for other fields in Oracle
#DML statements (data operator i) Insert, Update, Delete, Merge
#DDL statements (data definition i) Create, Alter, Drop, Truncate
# DCL statement (data control language i) Grant, Revoke
#Transaction control statement Commit, Rollback, Savepoint
#Authorization
grant connect, resource to cm;
# select userid||username from uesrinfos; ||Similarly add
#distinct to remove duplicate rows (affects efficiency Query row by row and column)
#When using like, remember to add an index to speed up
#select username from uesrinfos where instr(username,'zhang')!=0;
Fuzzy queries similar to like are slightly more efficient se
# select * from dual; The default table can be used for testing

#oracle function recitation
# select abs(-11) from dual;
#select ceil(11.5),ceil(-11.5) from dual; ceil positive right negative left
#select floor(11.5),floor(-11.5) from dual; floor Positive left and negative right
#select power(2,3) from dual; Return the value of 2 to the third power
#select exp(3) from dual; 
# select log(2,8) from dual; Find the power of 2 8
# select mod(10,3) from dual;
#select round (3.5) from dual;
#select trunc(3.9) from dual;
#select sqrt(100) from dual;
#select concat('a','b' ) from dual;
#select initcap('hello world,cm!!!are you ok') from dual;
capitalize the first letter #select lower('SSSXXXXXXXHelloAAA'
) from dual; ; All caps
#select instr('hello world hello hadoop','hello') from dual;
#select instr('hello world hello hadoop','hello',1,2) from dual;
#select lpad('1000',5,'0') from dual; 左补位
#select rpad('1000',5,'0') from dual; 右补位
#select trim(' abcd ') from dual; 去空格
#select trim('a' from 'abbd') from dual;  去a
#select substr('1308888888',3,8) test from dual; 截取字符串
#select add_months(birthday,3) from uesrinfos; 加3个月
#select last_day(sysdate) from dual;
#select months_between(sysdate,to_date('1999-9-12','yyyy-MM-dd')) from dual;
#select trunc(sysdate) from dual;
#select trunc(to_date('2022-6-23','yyyy-MM-dd'),'day') from dual;
#select next_day(sysdate,1) from dual; check the date
#select extract(YEAR from timestamp '1999-9-7 0:0:0') as dates from dual; intercept the year, month and day
#select current_timestamp from dual;
#select rowid,rownum,userid,username from uesrinfos; pseudo column rowid 
# select * from uesrinfos order by userid desc; query flashback
# select rownum no,a.* from uesrinfos a where rownum<=4;
# select * from (select rownum no,a.* from uesrinfos a where rownum<=4) tab where tab.no>2; oracle paging scheme #arrayList includes
before and after but does not include
#delete from emp e 
where e.rowid>( select min(x.rowid)
from emp x
where x.emp_no = e.emp_no
); Pseudo-class deduplication method
#delete from uesrinfos a where rowid>(select min(rowid) from uesrinfos b where a.username=b.username ); Delete duplicates
#select * from uesrinfos a where rowid=(select min(rowid) from uesrinfos b where a.username=b.username) Query is not duplicated
#select * from uesrinfos a where rowid=(1,2);
#mysql three ways to remove duplication distinct groupby pseudo column deduplication method 
#ALTER TABLE old_table_name RENAME TO new_table_name; (capitalized system command) 
#alter table userinfos rename column age to birthyear; modify column name

#
select sum(birthyear) from userinfos ;
select count(birthyear) from userinfos;
select e.e/d.d from (select sum(birthyear) e  from userinfos) e ,(select count(birthyear) d from userinfos) d;
#

#update userinfos set birthyear=(select ee/dd from (select sum(birthyear) e from userinfos) e ,(select count(birthyear) d from userinfos) d) where birthyear=null; vacancy supplement #select nvl(birthyear,
25 ) from userinfos; Vacancy supplement 2
#select userid,username,birthday,nvl(birthyear,ke) from userinfos ,(select avg(birthyear) e from userinfos) k; Vacancy supplement 3


 

Guess you like

Origin blog.csdn.net/just_learing/article/details/125377510