由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - question: copy first N rows from table B to table A (DB2)
相关主题
求教:数据操作Simple DB question
Help on Sql server huge table performancedata warehouse里面,所有dimension table的数据要拷贝到新的fact table里面,觉得这做法比较傻。
database triggersSQL question
urgent help! insert value into table做SQL题目,心脏病险些发作
急问一个关于T-SQL的问题,谢谢真服了老印
MS T-SQL 问题Urgent help!!!
Access database size急问一个奇怪的sql server数据库问题
In toad, 问一个SQL Server的问题
相关话题的讨论汇总
话题: rows话题: table话题: db2话题: select话题: first
进入Database版参与讨论
1 (共1页)
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.
1 (共1页)
进入Database版参与讨论
相关主题
问一个SQL Server的问题急问一个关于T-SQL的问题,谢谢
SQL find distinct values in large tableMS T-SQL 问题
关于in的效率Access database size
请问如何有效快速搜索一个很大的数据库?In toad,
求教:数据操作Simple DB question
Help on Sql server huge table performancedata warehouse里面,所有dimension table的数据要拷贝到新的fact table里面,觉得这做法比较傻。
database triggersSQL question
urgent help! insert value into table做SQL题目,心脏病险些发作
相关话题的讨论汇总
话题: rows话题: table话题: db2话题: select话题: first