【问题标题】:how to copy structure and data with specific column in visual foxpro如何在visual foxpro中复制具有特定列的结构和数据
【发布时间】:2014-03-30 18:53:06
【问题描述】:

请帮忙,我在 DBF 中有一个大型数据库,其中有 34 列和超过 50k 条记录。 在这种情况下,我只需要 34 列中的 10 列。从逻辑上讲,如果我删除不必要的列将减少数据负载。 所以我会从具有特定列的源文件中复制结构和数据,但我不知道如何在visual foxpro中做到这一点。

你会帮我处理这个案子吗?

前后,感谢您关注阅读我的问题。

问候,

悲观

【问题讨论】:

    标签: database structure dbf visual-foxpro


    【解决方案1】:

    使用以下语法:

    SELECT col1,col2,col3,col4,col5,col6,col7,col8,col9,col10 FROM table1 INTO TABLE table2
    

    【讨论】:

      【解决方案2】:

      如果您只想永久删除该列,首先,为了微笑,请制作文件的备份副本。然后,确保您没有使用该表的任何程序并启动 VFP。在命令窗口中,输入

      USE C:\SomePath\YourTable EXCLUSIVE   {enter}
      
      */ Now, get the one column you want copied out... you can just add as many
      */ Columns, such as any primary key reference you may also want to include to.
      COPY TheOneColumnYouWant to C:\SomePath\NewTableForThisColumnOnly  {enter}
      
      */ Now, to remove the column from the original table, now that is has been moved
      */ to the "other" table.
      MODIFY STRUCTURE {enter}
      

      这会打开一个修改表结构,您可以在其中更改/删除任何列。向下滚动列表到要删除的列,然后在底部单击“删除”按钮,然后单击“确定”按钮以确认结构更改。然后它会返回确认提示“使结构更改永久?”并选择是。列现已消失。

      在 VFP 中删除列的替代方法,您可以使用 Alter Table via...

      ALTER table C:\SomePath\YourTable DROP COLUMN TheOneColumnYouWant
      

      【讨论】:

      • 感谢您的回复先生,我不明白命令“COPY TheOneColumnYouWant to C:\SomePath\NewTableForThisColumnOnly”。其实我试过,“COPY column1,column2,column3,column4,column5,column6,column7,column8,column9,column10 to NewTableName”,但消息框出现“命令包含无法识别的短语/关键字”。
      • @Pathic,我提供的命令是示例。您需要输入自己的路径以及所需的任何列。如果你做“列表结构”,这些是你要查询/复制的列名。
      • 语法为:COPY TO NewTableName FIELDS column1,column2,column3
      • @LAK,无论哪种方式都可以...将字段复制到或复制到字段。
      • @DRapp,是的,我知道。这是一个例子。我分配了源表结构,但它错误。问题是命令。无论如何,谢谢。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-05
      • 2021-08-22
      • 1970-01-01
      • 1970-01-01
      • 2016-01-16
      • 2021-05-18
      • 1970-01-01
      相关资源
      最近更新 更多