Too Cool for Internet Explorer


Swobodin's Profile | Swobodin's Blog | Back to Fedora Tunisia

Vim+MySQL

After dumping some MySQL tables, whose the structure is the follwing:
CREATE TABLE `mydata` (
`id` tinyint(10) NOT NULL auto_increment,
`content` varchar(20) NOT NULL default '',
PRIMARY KEY  (`id`)
)  TYPE=MyISAM AUTO_INCREMENT=1 ;
INSERT INTO `mydata` VALUES ('1', 'First entry');

etc.
After dumping the tables, you want to drop the original tables from the database in order to replace the content; however, typing
DROP TABLE IF EXISTS `mydata`;
on each line would not be so easy if you had hundreds of tables.
You can fix that with vim : Edit the SQL file and execute the follwoing command:
:%s/\(^CREATE\ TABLE\ \)\(`.*`\)/DROP\ TABLE\ IF\ EXISTS\ \2\;\r&
Worked for me! :-)

Related posts

(sometimes, the plugin foolishes)
MySQL Server was down
WordPress Today Events
Snipper
Bad habits on the PC

Technorati tags

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

 
 

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a


Top Tunisie Blogs