dsl2014 2014-07-10 07:22
浏览 57
已采纳

如何编辑巨大的SQL转储?

I have a huge SQL-Dump with a lot of statements like

CREATE TABLE ...
INSERT INTO ...

and so on.

I want to edit this file. At first I want to delete all "CREATE TABLE" statements with all attributes. I only want the "INSERT INTO" statements. Is there an easy way? I'm a rookie at this area.

All "INSERT INTO" statements look like this:

INSERT INTO 'xyz' VALUES (a, b, c, d), (e, f, g, h), (c,d,e,g) ... 

I want to have it this way at the end:

INSERT INTO 'xyz' VALUES (<tenant_id>, a, b, c, d), (<tenant_id>, e, f, g, h), ...

Is there an easy way to realize that? E.g. with PHP or Regex? And how can I do this? Thank you!

  • 写回答

2条回答 默认 最新

  • doujiao3074 2014-07-10 08:39
    关注

    If u have access any unix like system I recommend this:

    sed '/CREATE TABLE */d' current.dump > new.dump
    

    it will remove all the create table lines and pipe the rest to a new dump file

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件