【问题标题】:Cannot get select into to work无法选择进入工作
【发布时间】:2016-03-27 14:45:23
【问题描述】:

我有一个数据库 squid 和一个表 configs

我正在尝试获取配置表into a different database [testsquid] on the same host

这是我尝试过的:

select * into testsquid.configs from squid.configs;

我首先尝试在testquid中不创建configs表,然后我实际上在testsquid中创建了configs表。

我正在尝试将配置表从 squid 获取到新的数据库 testquid。我决定不使用 mysql dump 因为它会锁定表。

我做错了什么?

【问题讨论】:

    标签: mysql select select-into


    【解决方案1】:

    如果表模式相同,您可以尝试:

    insert into testsquid.configs
        select * from squid.configs;
    

    如果新表不存在,创建它:

    create table testsquid.configs like squid.configs;
    

    更新:

    我不确定 insert-select 是否也会锁定表。为了缩短锁定时间,您可以使用没有任何索引的内存引擎创建类似的临时表。将数据复制到临时表中,然后将临时表中的数据复制到物理表中。

    【讨论】:

    • 好的,我如何将数据放入新的 testquid 配置表中?
    • 使用第一个查询传输数据。
    猜你喜欢
    • 1970-01-01
    • 2014-10-31
    • 2012-04-22
    • 2017-04-07
    • 2014-04-23
    • 2016-08-24
    • 2013-10-06
    • 2016-01-24
    • 1970-01-01
    相关资源
    最近更新 更多