Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1346985
  • 博文数量: 243
  • 博客积分: 888
  • 博客等级: 准尉
  • 技术积分: 2955
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-05 14:33
个人简介

漫漫长路,其修远兮!

文章分类

全部博文(243)

文章存档

2017年(2)

2016年(22)

2015年(32)

2014年(57)

2013年(107)

2012年(23)

分类: Mysql/postgreSQL

2013-01-06 17:14:42

原文地址:

其实很简单,就是利用正则表达式,从文件中抽取,可以用awk或sed,例如:

1. 抽取数据库 imysql_1 的全部SQL语句

#假设数据库 imysql_1 的下一个是 imysql_2
DBNAME1="imysql_1"
DBNAME2="imysql_2"
sed -n “/^-- Current Database: \`$DBNAME1\`/,/^-- Current Database: \`$DBNAME2\`/p” imysql_20100601.sql

2. 抽取数据表 user_base 的全部SQL语句

#假设数据表 user_base 的下一个是 user_detail
DBTAB1="user_base"
DBTAB2="user_detail"
sed -n “/^-- Table structure for table \`$DBTAB1\`/,/^-- Table structure for table \`$DBTAB2\`/p” imysql_20100601.sql

上面只是个例子,正则表达里面的表达式可以根据各自导出文件的内容进行修改

阅读(728) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~