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
Content Detail Tags: <h1>~<h6>Title T...
I recently watched a video of a foreign guy using...
There are two ways to delete data in MySQL: Trunc...
In general : [1 important flag] > [4 special fl...
Supervisor is a very good daemon management tool....
This article installs Google Input Method. In fac...
The filter attribute defines the visual effect of...
Table of contents Preface Architecture at a Glanc...
Beginners who are exposed to HTML learn some HTML...
Check the top 100 highest scores in game history ...
1. The role of brackets 1.1 Square brackets [ ] W...
Table of contents 1. Help Command 2. Mirror comma...
Table of contents Install Tomcat with Docker Use ...
<br />What is web2.0? Web2.0 includes those ...
This article example shares the specific code of ...