c***n 发帖数: 921 | 1 ** in db2 **
I have table B; now I want to create a new table A, which contains the first
500 rows from B.
I have created the structure of A, which is successfully executed.
Now I want to populate table A.
If I run:
insert into A (select * from B)
It populates A with all the rows from B;
If I run:
insert into A (
select * from B
fetch first 500 rows only)
It generates error "keyword fetch is not expected here"
How can I just get the first 500 rows from B? |
i***c 发帖数: 301 | 2 sql server:
select top 500 *
from B |
c*****d 发帖数: 6045 | 3 哪种数据库?ms sql, mysql, oracle?
ms sql: insert into A select top 500 * from B
mysql: insert into A select * from B limit 500
oracle: insert into A select * from B where rownum <=500
first
【在 c***n 的大作中提到】 : ** in db2 ** : I have table B; now I want to create a new table A, which contains the first : 500 rows from B. : I have created the structure of A, which is successfully executed. : Now I want to populate table A. : If I run: : insert into A (select * from B) : It populates A with all the rows from B; : If I run: : insert into A (
|
B*****g 发帖数: 34098 | 4 lz uses DB2, haha
【在 c*****d 的大作中提到】 : 哪种数据库?ms sql, mysql, oracle? : ms sql: insert into A select top 500 * from B : mysql: insert into A select * from B limit 500 : oracle: insert into A select * from B where rownum <=500 : : first
|
w*r 发帖数: 2421 | 5 in Teradata:
insert into A select * from B qualify row_number() over (order by col1,
col2, colN) <=500
【在 c*****d 的大作中提到】 : 哪种数据库?ms sql, mysql, oracle? : ms sql: insert into A select top 500 * from B : mysql: insert into A select * from B limit 500 : oracle: insert into A select * from B where rownum <=500 : : first
|
w*r 发帖数: 2421 | 6 SELECT * FROM MYSALES FETCH FIRST 500 ROW ONLY
【在 B*****g 的大作中提到】 : lz uses DB2, haha
|
j*****n 发帖数: 1781 | 7 Open your DB2 help file please, get in depth look about the SELECT
statements. |