Rownum is a unique way of writing in Oracle. In Oracle, rownum can be used to retrieve the first piece of data or to limit the number of batches to be written when writing data in batches. How to write the first data in mysql SELECT * FROM t order by id LIMIT 1; How to write the first data in oracle SELECT * FROM t where rownum =1 order by id; OK, the above is a comparison of the writing methods of MySQL and Oracle to get the first data, but this is only one usage of rownum. Rownum can also be used to write data in batches. Write 10,000 records to table t in batches: insert into t(id,date) select sys_guid(),sysdate from dual connect by rownum<=10000; Oracle original writing: select * from (select id,name from t) where rownum <![CDATA[<=]]> to_number(num); SQL rewritten by mysql: SELECT * FROM (SELECT tb.*, @rownum := @rownum + 1 AS rownum FROM (SELECT id, NAME FROM t) tb, (SELECT @rownum := 0) r) AS t WHERE rownum <= CAST(num AS SIGNED INTEGER); The above is all the knowledge points introduced this time. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: jQuery implements employee management registration page
>>: How to install Linux system (Redhat8) and virtual machine network configuration in VMware
Table of contents 1. Backup 1.1 Fully prepared 1....
You can use the attribute in HTML5 <input="...
Step 1: Change DATABASES in setting.py # Configur...
1 Background Recently, I have been studying how t...
Table of contents Date Object Creating a Date Obj...
Text Shadow text-shadow: horizontal offset vertic...
MySQL's CAST() and CONVERT() functions can be...
Standardized design solutions - markup languages ...
Table of contents Introduction to stored procedur...
Table of contents 1: Single machine password-free...
Implemented according to the online tutorial. zab...
HTML is a hybrid language used for publishing on ...
In MySQL, you can specify multiple indexes for a ...
1. Background Netplan is a new command-line netwo...
Dynamic rem 1. First, let’s introduce the current...