如何分割FoxPro记录?

发布于 2024-10-26 07:53:46 字数 161 浏览 4 评论 0原文

我在 FoxPro 的 dbf 文件中有 60,000 条记录。我想将其分成每 20,000 条记录 (20000 * 3 = 60,000)。

我怎样才能实现这个目标?

我是 FoxPro 的新手。我使用的是 Visual FoxPro 5.0。

提前致谢。

I have 60,000 records in the dbf file in FoxPro. I want to split it into each 20,000 records (20000 * 3 = 60,000).

How can I achieve this?

I am new to FoxPro. I am using Visual FoxPro 5.0.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

红墙和绿瓦 2024-11-02 07:53:47

如果您不关心记录如何分割,托德的建议将会起作用。如果您想根据内容对它们进行划分,您需要执行 Stuart 的第一个建议,尽管他的确切答案仅在记录 ID 按顺序从 1 到 60,000 运行时才有效。

这里的最终目标是什么?为什么要分桌子?

添马舰

Todd's suggestion will work if you don't care how the records are split. If you want to divide them up based on their content, you'll want to do something like Stuart's first suggestion, though his exact answer will only work if the IDs for the records run from 1 to 60,000 in order.

What's the ultimate goal here? Why divide the table up?

Tamar

长安忆 2024-11-02 07:53:47

你可以直接从第一个表中选择:

SELECT * from MyBigTable INTO TABLE SmallTable1 WHERE ID < 20000
SELECT * from MyBigTable INTO TABLE SmallTable2 WHERE ID BETWEEN (20000, 39999)
SELECT * from MyBigTable INTO TABLE SmallTable3 WHERE ID > 39999

但是,如果你想要更多的控制,或者你需要操作数据,你可以使用xbase代码,像这样:

SELECT MyBigTable

scan
    scatter name oRecord memo

    if oRecord.Id < 20000
        select SmallTable1
        append blank
        gather name oRecord memo
    else if oRecord.Id < 40000
        select SmallTable2
        append blank
        gather name oRecord memo
    else 
        select SmallTable3
        append blank
        gather name oRecord memo
endscan 

自从我使用VFP以来已经有一段时间了,我没有它在这里,对任何语法错误表示歉意。

You can directly select from the first table:

SELECT * from MyBigTable INTO TABLE SmallTable1 WHERE ID < 20000
SELECT * from MyBigTable INTO TABLE SmallTable2 WHERE ID BETWEEN (20000, 39999)
SELECT * from MyBigTable INTO TABLE SmallTable3 WHERE ID > 39999

if you want more control, though, or you need to manipulate the data, you can use xbase code, something like this:

SELECT MyBigTable

scan
    scatter name oRecord memo

    if oRecord.Id < 20000
        select SmallTable1
        append blank
        gather name oRecord memo
    else if oRecord.Id < 40000
        select SmallTable2
        append blank
        gather name oRecord memo
    else 
        select SmallTable3
        append blank
        gather name oRecord memo
endscan 

It's been a while since I used VFP and I don't have it here, so apologies for any syntax errors.

两人的回忆 2024-11-02 07:53:47
use in 0 YourTable
select YourTable
go top
copy to NewTable1 next 20000
copy to NewTable2 next 20000
copy to NewTable3 next 20000
use in 0 YourTable
select YourTable
go top
copy to NewTable1 next 20000
copy to NewTable2 next 20000
copy to NewTable3 next 20000
温柔嚣张 2024-11-02 07:53:47

如果您想根据记录数进行拆分,请尝试以下操作:

SELECT * FROM table INTO TABLE tbl1 WHERE RECNO() <= 20000
SELECT * FROM table INTO TABLE tbl2 WHERE BETWEEN(RECNO(), 20001, 40000)
SELECT * FROM table INTO TABLE tbl3 WHERE RECNO() > 40000

If you wanted to split based on record numbers, try this:

SELECT * FROM table INTO TABLE tbl1 WHERE RECNO() <= 20000
SELECT * FROM table INTO TABLE tbl2 WHERE BETWEEN(RECNO(), 20001, 40000)
SELECT * FROM table INTO TABLE tbl3 WHERE RECNO() > 40000
听不够的曲调 2024-11-02 07:53:46

使用COPY 命令时必须发出SKIP 命令以确保开始下一条记录。

USE MyTable
GO TOP
COPY NEXT 20000 TO NewTable1
SKIP 1
COPY NEXT 20000 TO NewTable2
SKIP 1
COPY NEXT 20000 TO NewTable3

You must issue a SKIP command when using the COPY command to make sure you are starting on the next record.

USE MyTable
GO TOP
COPY NEXT 20000 TO NewTable1
SKIP 1
COPY NEXT 20000 TO NewTable2
SKIP 1
COPY NEXT 20000 TO NewTable3
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文